Ju Lin

Ju Lin

Ju Lin is the author behind Enqueue Zero. He likes web programming, system programming, algorithms, and architecture.

Latest Posts

The Architecture of APScheduler

APScheduler is a job scheduling framework that executes code either one-off or periodically. People often integrate it into an existing Python application for running interval jobs.

In this post, we will cover below topics:

  • What are the basic concepts of APScheduler?
  • How does object-oriented programming help extending the use cases …

Pseudo-Random Numbers

Overview

PRNG or Pseudo-random number generators are used for generating numbers distributed randomly.

The reason of being pseudo-random is that the PRNG algorithm doesn't generate true-random information actually.

Terms

  • RNG: Random Number Generators. It's a general classification regardless of generating psuedo-random or true-random numbers.
  • PRNG: Pseudo-Random Number Generators. The pseudo …

Layered Architecture

Overview

The layered architecture has several other names, such as onion architecture, the clean architecture, etc. The basic theory is, you organize the components layer by layer in which only the upstream layer can make calls to the downstream layers.

Most systems are designed in the layered architecture.

Use

  • MVC …

2018.36

Dear my funders, there is a tremendous change on UI this week!

It's based on Pelican and theme Medius. Almost all old posts have been migrated into the new blog. Besides, I added Disqus comment widget and tagging system.

Below is a sample screenshot.

New Look

Any feedback, please let me know …

2018.35

Dear my funders, here comes the new issue.

Two-Phase Locking. The 2PL is the basic algorithm in relational database.

Airbnb Architecture. It's quite interesting to outline the architecture of Airbnb without knowing too much details. Fortunately, the Airbnb engineering blog reveals a lot of information so that we can know …

Airbnb Architecture

Overview

Airbnb is a website that operates an online marketplace and hospitality service for people to lease or rent short-term lodging. The challenges for the engineering team includes high-availability, quick-scaling, etc. In this post, I put the architecture of Airbnb website in one article. Please tweet to @enqueuezero if you …

2PL

The 2PL or Two-Phase Locking is a method to reach serializability.

2018.34

Dear my funders,

This is the weekly newsletter on Enqueue Zero new posts. I'm trying to break down topics into small posts. The tiddlywiki has a nice feature that it can include some other notes into one note, for example, this is the raft topic that compiles from below three …

Timezone

Context

As the earth is a sphere, different places in the world will have different clocks. Human invented timezone to split the globe into 24 areas by regions. The UTC or Coordinated Universal Time is the primary time standard by which the world regulates clocks and time.

Programmers need to …

Periodic Scheduler

Context

It’s a fundamental requirement that we need to run a command at a specific time.

Overview

Periodical Scheduler schedules code to be executed periodically. It has below features:

  • Job managing, meaning adding new jobs, removing old ones, or modifying existing ones.
  • Job storing.
  • Run as a long-running process …

The Difference between SLI, SLO, and SLA

The SLA, SLO, and SLI are related concepts though they're different concepts.

  • SLA or service level agreement is a contract that the service provider promises customers on service availability, performance, etc.
  • SLO or service level object is a goal that service provider wants to reach.
  • SLI or service level indicator …

Raft and Stream Paradigm

The stream is a data structure that evaluates data when we need them. Below is a typical Python Stream.

from functools import lru_cache

class Stream:

    def __init__(self, head, restfn=None):
        self.head = head
        self.restfn = restfn

    @property
    def stopped(self):
        return self.restfn is None

    @property
    @lru_cache()
    def rest …

Raft and Unreliable Network

The synchronization of the Raft states among nodes in the cluster imposes order on messages. However, the unreliable gears make the ordering very difficult. Sometimes, it plays like a thief stealing your data packets. Sometimes, it plays like a jerk swapping the order of data packets sending to a node …

Raft and The Nature of Time

The Raft consensus algorithm assumes nodes are in the vicinity, meaning they should be able to communicate very fast. Let's imagine the case of one node on Earth, one node on Mars, and one node on the Moon. It would take minutes for messages communicating between nodes and hence minutes …

2018.30

Dear my pledgers, here comes our new issue.

  • FFI. Foreign Function Interface is a bridging technology between VM languages and shared libraries. I wrote this post after a tough battle in implementing FFI in my previous educable scripting language ao. Besides, I introduced Grammarly to help improving grammar and verbals …

Container and Cgroups

Cgroups is a Kernel feature that organizes processes into hierarchical groups to limit and monitor their system usage such as CPU, memory, disk, network and so on.

The Linux kernel provides a pseudo-filesystem named cgroupfs as the interface. A cgroup is a set of processes which has settings in cgroupfs …

Container and UnionFS

Union File System or UnionFS variants such as AUFS, btrfs, vfs, and devicemapper are the file system that used by most container engines. It allows files and directories of separate file systems overlaid one by one, forming a final single coherent file system.

A typical pattern is that we define …

Container and Namespace

Namespace enables us having the same name for some global system resources. For example, A PID namespace empowers the process inside the namespace running with 1 as PID, which at the same time, init is running with 1 as PID in the regular namespace.

Container PID namespace

The namespace has various kinds. You …

Container and nsenter

Nsenter is a utility enters the namespaces of one or more other processes and then executes the specified program. In other words, we jump to the inner side of the namespace.

Keep above unshare command running, and let's create a new session. This time, we run a program in the …

Container and unshare

Unshare is a utility running program with some namespaces unshared from a parent. We create a new PID namespace below.

[user@julin1 ~]$ sudo unshare --fork --pid --mount-proc sh
[sudo] password for user: 
sh-4.2# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0 …