Some tips for building Docker images

In my previous blog on how Docker (containers) works, I described how Docker image works. In simple terms, it uses Linux’s overlayfs, overlay file system, to merge two file systems together, with the lower file system being read-only and the upper file system being writable. If you read, you find the upper layer and read the upper layer, otherwise you find the lower layer and read it to you. Then if you write, you write to the upper layer.

Emacs Getting Started Guide: Why & How

When it comes to Emacs, every programmer should have more or less heard of its name, after all, Emacs has a long history of nearly forty years. However, the high threshold for Emacs “entry” has led many beginners to abandon it before they can appreciate its essence. Before I became “proficient” in Emacs, I was also abused by it, so after using Emacs for four years, I think I can

Prometheus Storage Engine Analysis

Prometheus is one of the most popular monitoring platforms in the cloud-native era as a temporal database. Although its overall architecture has not changed much, the underlying storage engine has evolved over several versions. This article focuses on the details of the storage format of Prometheus V2 version (which is mainly used now) and how queries locate the eligible data, aiming to have a deeper understanding of the storage engine

How to design a thread pool in C++

In this post we explore the key techniques in thread pooling by implementing it step by step. Preliminary discussion Why do I need thread pools? Using threads in C++ has been easy since C++11. At the most basic level, a thread can be managed with std::thread. For asynchronous execution of tasks, it is also convenient to use std::async and std::future. With all this infrastructure in place, why do we need a thread pool?

Unplugin Vue Components

unplugin-vue-components (later called plugins) is a plugin that automatically introduces vue components on demand, and is a masterpiece of Antfu. Requirements It is common to bring in component libraries on-demand in order to reduce the project size. However, if you use component library content very frequently in your project, or even need to introduce multiple component libraries, this can become very cumbersome, potentially requiring a dozen components to be imported

Getting to know WebSocket

Birth of WebSocket In 2005, with the birth and application of AJAX technology, it became possible to request data from a web page to a server and render the page dynamically. HTTP is a one-way transmission protocol that can only be sent by the client, and it is really difficult to obtain continuous real-time information. People started this fancy exploration of real-time access to information technology. Relying on the HTTP protocol, the more widespread way is polling.

Use of VictoriaMetrics Clustering Mode

Earlier we described the use of the single-node version of VictoriaMetrics. For ingestion rates below one million data points per second, it is recommended that the single-node version be used instead of the clustered version. The single-node version scales with the number of CPU cores, RAM, and available storage space. The single-node version is easier to configure and operate than the clustered version, so think twice before using the clustered

React official team to make up for the shortcomings of the native Hook

We know that there is a so-called closure trap in the use of Hooks, consider the following code. 1 2 3 4 5 6 7 8 9 function Chat() { const [text, setText] = useState(''); const onClick = useCallback(() => { sendMessage(text); }, []); return <SendButton onClick={onClick} />; } We expect sendMessage to pass the latest value of text after a click. However, in reality, the effect of the click

Raft Consensus Algorithm

Distributed Systems and Consistency Distributed systems have a very important problem to solve. When one machine has a problem, we want the whole cluster to still be able to run normally to meet the requirement of high availability. Because the data of the system is constantly changing, it is important to ensure that the data of the cluster is synchronized, or else there will be data mix-ups or loss. This is the consistency problem.

New changes to the atomic package

Russ Cox mentioned changes to the atomic package in his series of articles last year and opened an issue for discussion, and now that the changes he committed have merged to the master branch, Go 1.19 will include those changes. You can also use gotip to learn about these changes in advance. This commit by Russ Cox simply adds some new types to atomic, which are a wrapper around primitive types (such as bool, int32, int64, uint32, uint64, uintptr, etc.

In-depth understanding of OC/C++ closures

Apple’s Objective-C compiler allows users to freely mix C++ and Objective-C in the same source file, and the resulting language is called Objective-C++. Compared to other languages (e.g. Swift, Kotlin, Dart, etc.) that use file isolation and bridge communication with C++ (e.g. Kotlin uses JNI and Dart uses FFI), Objective-C and C++’s same-file mashup is certainly comfortable. Although OC/C++ mashups can be written in a single file, there are some

The father of Node.js talks about JavaScript containers

Node.js and Deno founder Ryan Dahl’s “JavaScript Containers” article published yesterday presents a vision of a future in which new container-like abstractions will emerge to simplify servers. Most Web services can be simplified by JavaScript containers rather than Linux containers. In this emerging server abstraction layer, JavaScript replaces the Shell. He proposed a vision to make JavaScript the standard language for containers. This way, containers could be standardized, and developers would not have to build their own container image files, but just throw JS scripts into the standardized containers.

Anaconda Launches PyScript: Embedding Python Code in HTML

The developers of Anaconda, a leading Python distribution, have recently announced PyScript, a Python that runs in the browser. According to the official description, PyScript is a development framework that provides developers with the ability to write Python code embedded in standard HTML, call JavaScript libraries using Python, and create Python web applications. PyScript aims to provide a “first-class” programming language with consistent stylization rules, more expressiveness, and easier learning.

ETCD's memory problem

Today I’d like to share with you a problem with the large memory footprint of etcd, a problem we encountered some time ago in our open source software Easegress. The problem is relatively simple, but I also want to talk about the causes and consequences, including, why we use etcd, the user scenarios using etcd, including some designs of etcd that lead to a relatively large memory footprint, and finally some suggestions.

Stack Overflow introduces a new copy/paste keyboard with "light pollution"

On April Fool’s Day last year, Stack Overflow announced a keyboard with only Ctrl, C, and V. At the time, officials teased that it would limit the number of times users could copy and paste code from websites, and that developers would need to buy a special keyboard if they wanted to use it indefinitely. Once announced, the keyboard attracted the attention of many developers, who asked Stack Overflow to mass produce it.

C++ Standard Library: Concurrency (2) -- Low-level interfaces thread and promise

The thread-related api can be introduced via #include <thread>, and the promise-related api is in #include <future>. std::thread’s join and detach Unlike the std::async method of starting asynchronous tasks, std::thread will unconditionally start a task in a separate thread and begin execution If you want the current thread to wait until it knows that thread t has finished executing, then call t.join() If the intention is to detach thread t

Getting started with rollup.js, a packaging tool

rollup.js is a JavaScript packaging tool. This article describes its basic usage. 1. Introduction The purpose of the packager tool is to combine multiple JavaScript scripts into a single script for the browser. Browsers need script packaging for three main reasons. Early browsers did not support modules, and large web projects could only be merged into a single script before execution. The module mechanism of Node.js is not compatible with browsers and must be handled for compatibility by packaging tools.

Linux system UDP packet loss problem analysis ideas

I recently encountered a server application UDP packet loss in my work, and after reviewing a lot of information in the process of troubleshooting, I summarized this article for more people’s reference. Before we start, let’s use a diagram to explain the process of receiving network messages on a linux system. first, the network message is sent to the NIC(Network Interface Controller) through the physical network cable the network driver

Guide to using the linux lsof command

lsof Introduction lsof is short for list open files, and as the name suggests, its purpose is mainly to list open files on the system. At first glance, it seems to be a very simple command with few scenarios, but it is just another version of ls. But because of the unix philosophy of everything is a file, basically all objects on a *nix system can be considered as objects, and with the various arguments provided by this command, it is actually very powerful and can easily get a lot of very useful information, some of which would be very troublesome with other tools.