Container

Many people have heard of the container for a while or even use it every day. However, a question like "what is container" or "how container works" might still rise.

In this post, we will deep dive into the container.

Context

Before container era, we usually use visualization technology to …

FFI

Context

C function parameter types and return type are nowhere in compiled shared dynamic library. Some other programs may not know what arguments are to be passed to a function in this program.

In Python, we can dynamically load a dynamic library, resolve FuncPointers by symbols of functions and even …

Coroutine

Context

Although thread is much more lightweight than process, people still think it's too heavy. In Linux kernel, creating a thread still need to assign same amount of memory like process. Therefore, a more lightweight solution needs to reduce memory usage.

Micro-threads, or usually named as coroutine, is such kind …

2018.28

Hello everyone, two weeks passed. Now I bring all ya some new posts.

  • New 404 Page. I try to glue all potential topics into one posts and has integrated about 100 topics into it. I will grow it and make it as another kind of table of index.

  • Load. This …

Load

Context

A system might perform very bad sometimes, and thus we need something to measure how bad it is.

Generally such metric is called Load.

Overview

Load is a set of numbers that describe performance of system. The meaning of numbers depends on what system is running. For example,

  • A …

Language Grammar

Context

There are growing number of programming languages. Each specific domain of problem might eventually derive a dedicated optimized programming language. We have below nontrivial languages that has been well adopted in programming world.

  • Assembly Languages.
  • System Programming Languages, such as C, C++, Rust, Go, Pony, etc.
  • Scripting Languages, such …

2018.26

Kia ora, my pledgers. Yet another great weekends. First thing first, let's count what we have this week:

  • Post: Back-pressure. Not much to say on this post. It's easy and short one. Very simple but powerful strategy to keep the system away from crashing.

  • Post: URL Dispatcher. I compared several …

URL Dispatcher

Context

URI links live everywhere outside the website itself, so we tend to change URIs as less as possible. Check more on Hypertext Style: Cool URIs don't change.

Most modern web frameworks provide a component called Router or URLDispatcher to resolve a function or method to handle requests to URLs …

Back-Pressure

Producer-consumer model is very helpful to decouple the system components. However, the situation is quite often in which producer produces jobs more rapidly than consumers can consume them. It's a challenge to manage a large number of unconsumed jobs.

Actor Model

The actor is an isolated concurrent unit scheduled by the programming language.

Lock-free Queues

Context

FIFO queue is an important data structure. Queues are also being implemented in many other algorithms, such as quick-sort.

Applying queue data structure to concurrency is important. This data structure enables us to distribute information from one execution unit to another. However, it enforces us to make sure data …

Load Balance

Context

When the load in a single machine can't bear so much traffics, a natural solution is to distribute load on several machines.

It introduced a new problem to us: how to distribute traffics to several machines? This kind of problem is called load balancing.

Introduction

Round-Robin DNS

The simplest …

Asynchronous and Synchronous

Context

In computing, program doing input / output, or I/O, has five major ways:

  • Blocking I/O
  • Non-blocking I/O
  • I/O Multiplex
  • Signal-driven I/O
  • Asynchronous I/O

Check I/O Models if you don't understand them.

In programming language, the last I/O - Asynchronous I/O and others …

Circuit Breaker

Context

In a distributed system, an application often has at least one upstream system. When upstream is overloaded, or doomed to fail, the application is very likely to be bogged down as well. Such circumstance is called cascading failure.

As an example, we have an application requiring a remote service …

Secure Socks5 Proxy

Context

In HTTP / HTTPS world, the source and destination of a TCP/IP packet is in public. A malicious party can interfere the network connection and send the source with a poisoned packet to deter or abort the connection.

Known attack techniques include:

  • IP blocking. Malicious party blocks any connection …

In-Memory Database

Context

Accessing data in memory can be faster than from disk.

In-memory database is a database that keeps the entire dataset in RAM. So it generally has better performance than on-disk databases.

Use

  • When fast data access is a criterion.
  • Used as caching layer in front of on-disk databases.

Common …

Hyperloglog

HyperLogLog is an algorithm that can solve Count Distinct problem. A Count Distinct problem is something like getting number 5 for a data set like [1, 3, 2, 1, 5, 2, 4], for it has [1, 2, 3, 4, 5] 5 elements.

HyperLogLog can provide estimated count on a very …

Time-consuming Jobs

Context

A reactive system needs to respond quickly, maybe in less than 500 ms or 1 second.

However, it's inevitable that some jobs need to run for long, maybe even in a few hours.

It's impossible to achieve both goals without changing the execution model, to keep the system responsive …

Job Queue

Context

In request-response model server usually has very short time to run transactions, and thus it doesn't have enough time to handle time-consuming jobs. For example, the web server needs to respond in less than 30 seconds, while an API importing his/her data might need to take 5 minutes …

Data Serialization

Context

Processes need to interact with each other and hence they need to speak in same language. The serialization is the process of translating data structures and code objects into data stream in a format that can be stored or transmitted and deserialize back to origin data structure and code …