Everything you need to know about Promise

Promise is one of the best APIs for asynchronous operations in JavaScript. As a JavaScript developer, you need to be proficient in Promise. This article will summarise this knowledge, starting with a review of how JavaScript has handled asynchronous operations in the past? Then we’ll go into detail about the Promises object and its associated methods. Let’s start with a look at JavaScript asynchronous concepts. Asynchronous What is asynchronous? A

TCP/IP protocol optimisation for large websites

As a site with millions or tens of millions of DAUs, it is not only necessary to optimize the web application and database, but also the TCP/IP protocol layer. In my work, I have used the following basic optimisation approaches. Increasing the maximum number of connections In Linux, all network connections are made via file descriptors, so the number of file descriptors a process can open determines the maximum number of connections it can create.

Systemd common operations and configuration

Most Linux distributions are now managed by systemd, which is becoming more and more complex, but there are only so many common operations, so today I will talk about my own common operations and configuration. Operation daemon-reload When adding a new service to a system, it is common to keep changing the test.service configuration file. After changing the configuration file, it is usually necessary to run systemctl daemon-reload to re-add

6 methods of communication between Svelte components

The main challenge in designing user interfaces using components is managing the application state on different components. Svelte provides a powerful capability to enable data passing between components. “Great communication begins with connection.” — Oprah Winfrey Note: Oprah Gail Winfrey (born 29 January 1954) is an American television talk show host, producer, investor, philanthropist and actress, one of the most influential African-American celebrities in the United States, and one of the top 100 people of Time.

Building more modern app widgets in Android 12

Widgets have been an important part of Android since 2008 and are an important aspect of customising the home screen. You can think of a widget as an ‘at-a-glance’ view of the app, giving the user a glimpse of the app’s data and core functionality without having to open the app from the home screen. But the AppWidget API has remained largely unchanged since the launch of Android, with only

Analysis and resolution of memory cgroup leaks

Memory cgroup leaks are a common problem in K8s (Kubernetes) clusters, resulting in nodes being stretched for memory resources, or nodes becoming unresponsive and having to restart the server to recover. Most developers use regular drop cache or disable kernel kmem accounting to circumvent this problem. This paper analyses the root cause of memory cgroup leaks and provides a solution to fix the problem at the kernel level, based on a practical example from the NetEase Digital Sail kernel team.

Ubuntu lowers the hardware barrier even further - support for running on a Raspberry Pi 4 with 2GB of RAM

Ubuntu already supports the 4GB and 8GB memory versions of the Raspberry Pi 4 Model B (supported since Ubuntu 20.10). Now the Ubuntu team plans to lower the hardware barrier for Ubuntu even further by making the upcoming Ubuntu 22.04 LTS version to run on a Raspberry Pi 4 with only 2GB RAM. However, getting a full Linux system like Ubuntu to run properly on a hardware device with too little memory can be difficult, so how does Ubuntu do it?

Website URL design is not simple

URIs and URLs and URNs URLs are familiar, the other two terms are more unfamiliar. URIs, URLs and URNs are standard ways to identify, locate and name resources on the Internet. invented by Tim Berners-Lee in 1989, the World Wide Web (WWW) is considered a globally interconnected collection of physical and abstract resources -It provides information entities on demand - accessible via the Internet. The actual resources range from documents to people, while the abstract resources include database queries.

A detailed explanation of email port numbers

E-mail (E-mail) is one of the oldest protocols on the Internet, but it is also the most widely used communication protocol today. For historical reasons, e-mail uses many different protocols and each protocol uses a different TCP port, which greatly increases the difficulty of setting up e-mail and is very unfriendly to users who do not know computer expertise. Today, we will introduce the relevant protocols and ports systematically, and try to clear the obstacles for novice users.

CPS transformations for Kotlin Coroutine

Most implementations of coroutines are based on some kind of runtime yield primitive. However, kotlin does not have this kind of lower-level support, and still implements coroutines based on CPS transformations on jvm, which does not have yield instruction support. It’s actually quite impressive, and I’d like to know how it’s done. CPS Transformation CPS stands for Continuation Passing Style, which is basically code that looks like this. 1 2 3 4 5 function auth(token, resourceName) { let userId = loginUser(token) let ok = checkPermission(userId, resourceName) return ok ?

ZGC Notes: Colored Pointers

ZGC is a new generation of garbage collector introduced from jdk11, the expected stopping time is less than 10ms, and the stopping time is independent of heap size, and it can support tb-level heap. As a fan of go, isn’t go’s GC already pretty good? The Initial Mark has a little STW, and the usual gc pause is less than ms? In fact, the effect of go GC is still far from the promise of ZGC, not when it comes to large heaps.

badger transaction process

badger is dgraph’s open source LSMTree KV engine, which has KV separation, transaction, concurrent merge and other enhancements compared to leveldb, and is a more production-level storage engine in the go ecosystem. Here is a look at its transaction implementation. badger implements Serializable Snapshot isolation level (SSI) for optimistic concurrency-controlled transactions. Compared to Snapshot isolation level (SI), SSI tracks read operations in a transaction in addition to write operations for

Rocksdb transactions

rocksdb supports both PessimisticTransactionDB and OptimisticTransactionDB concurrency control modes, both of which seem to be external wrappers for DB objects, doing concurrency control outside of the storage, allowing applications to do transactional KV read and write capabilities per BEGIN, COMMIT, ROLLBACK APIs. rocksdb originally has the ability to write WriteBatch atomically, and the transaction does things on the basis of WriteBatch, where writes within the transaction are temporarily stored in

cockroachdb two-stage commit process

Previously, I only knew a little bit about percolator, and my impression of it is that it can implement transaction capability on top of a common distributed KV storage, but the overhead of 2PC + raft process is considerable. A few days ago, I heard that cockroachdb has made some engineering optimizations compared to percolator, so I’d like to learn how to implement this part. The same as percolator, crdb also implements multi-line transaction management according to decentralized transaction manager.

Go Generic Programming: Specialization Support

Some programming languages such as C++ and Rust support generic specialization, does Go generic support it? Specialization is an extension of the generic function code. For example, for a generic function, its implementation is the same for all types (type sets) that satisfy the generic argument. If we want to do a special implementation of the function for one of these type sets, some languages that support generic specialization can

Auto-tuning GOGC - optimizes GO's GC CPU usage

Uber recently posted an article that focuses on dynamically tuning GOGC on core services to reduce the mark phase CPU usage of GC. Basically, it is effective, low-risk, scalable and semi-automated. Uber’s current service scale is about a few thousand microservices, based on the scheduling infrastructure on the cloud for deployment. Most of the services are written by GO, and the author of this article is doing Maps Production Engineering, a group that has helped some Java systems to adjust GC parameters before (this should be the starting point for them to help Go to do optimization and think about how to adjust parameters).

Google VP criticizes Apple iMessage for "green bubble bullying" of Android users

On the morning of January 8, the Wall Street Journal published an article titled “Why Apple’s iMessage Is Winning: Teens Dread the Green Text Bubble, which pointedly pointed out some of the problems with Apple’s iMessage instant messaging application: Apple users use the blue text bubble by default in iMessage, and because Apple forces Andriod devices to use SMS (short message service) instead of sending messages over network data, Android devices are not able to send messages over the network.

Gunicorn Signal Processing

I recently used Gunicorn’s Graceful Shutdown feature in a project, so I read the code to learn about Gunicorn’s signal processing. Master Gunicorn starts with. 1 2 3 WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run() BaseApplication().run() Arbiter(self).run() The main control logic of the Master is implemented in Arbiter, including the signal handling and main loop logic. A call to Arbiter().run() will eventually lead to a call to Arbiter.init_signals(), where the signal functions defined in

Linux audit buffer configuration

Recently, I encountered a case where a host was in a hung state, and the IPMI console of the host at that time showed the log: audit: backlog limit exceeded, and for some reasons, the NMI signal was not sent in time to trigger the kernel core dump, so I could only troubleshoot according to the existing information, and recorded the following audit buffer related configuration learning. Audit The Linux kernel introduced audit in 2.

DHCP lease life cycle

Yesterday, I was working with a colleague to troubleshoot a problem with a VM IP change, so I just wanted to organize the DHCP lease life cycle and the change process. DHCP lease lifecycle Allocation: A client starts with no valid lease, and therefore no DHCP-assigned address. It acquires a lease through an allocation process. Reallocation: If a client already has an address from an existing lease, then when it reboots or starts up after shutdown, it contacts the DHCP server that granted it the lease to confirm the lease and obtain operational parameters.