<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Blogs</title><link>https://hbisheng.github.io/blogs/</link><description>Recent content on Blogs</description><generator>Hugo</generator><language>en-us</language><copyright>Bisheng Huang</copyright><lastBuildDate>Thu, 28 Dec 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://hbisheng.github.io/blogs/index.xml" rel="self" type="application/rss+xml"/><item><title>(Notes) Go GC algorithm</title><link>https://hbisheng.github.io/blogs/programming-language/go-gc/</link><pubDate>Thu, 28 Dec 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/programming-language/go-gc/</guid><description>&lt;p&gt;Go is a language with automatic GC (garbage collection). The GC process uses a tri-color mark-and-sweep algorithm.&lt;/p&gt;&#10;&lt;h3 id="tri-color-algorithm"&gt;Tri-color algorithm&lt;/h3&gt;&#10;&lt;p&gt;&lt;strong&gt;Two stages&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Mark phase: mark objects that are reachable. It&amp;rsquo;s a directed graph problem. You start from a set of root objects (e.g. global variables, pointers from the stack to the heap) and process all objects referenced directly or indirectly.&lt;/li&gt;&#10;&lt;li&gt;Sweep phase: reclaim objects that are not reachable. This doesn&amp;rsquo;t happen synchronously but amortizes over new memory allocations.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;&lt;strong&gt;Three colors&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>Basic Infrastructure Components</title><link>https://hbisheng.github.io/blogs/infrastructure/intro/</link><pubDate>Sun, 28 May 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/infrastructure/intro/</guid><description>&lt;p&gt;This post talks about basic infrastructure components that are regarded as common knowledge among software engineers.&lt;/p&gt;&#10;&lt;h2 id="infrastructure-components"&gt;Infrastructure components&lt;/h2&gt;&#10;&lt;h3 id="code-management"&gt;&lt;strong&gt;Code management&lt;/strong&gt;&lt;/h3&gt;&#10;&lt;p&gt;Code is at the core of software engineering. &lt;strong&gt;Git&lt;/strong&gt; can be used to manage the codebase; it provides version control and allows for large-scale collaborations.&lt;/p&gt;</description></item><item><title>Database Consistency Model</title><link>https://hbisheng.github.io/blogs/database/consistency-model/</link><pubDate>Mon, 20 Mar 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/database/consistency-model/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Consistency is a problem when your system stores multiple copies of the same data. Consistency levels allow us to reason about the guarantees provided by a database system and what outcomes are allowed/forbidden.&lt;/p&gt;</description></item><item><title>The physics of a transistor</title><link>https://hbisheng.github.io/blogs/hardware-physics/transistor/</link><pubDate>Thu, 12 Jan 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/hardware-physics/transistor/</guid><description>&lt;p&gt;The transistor is one of the marvelous inventions of human beings and yet they are so common in our lives. This post attempts to uncover some of the physical makeup and characteristics of a transistor.&lt;/p&gt;</description></item><item><title>A mental model of program execution from logical functions</title><link>https://hbisheng.github.io/blogs/computer-architecture/program-exec-mental-model/</link><pubDate>Tue, 04 Oct 2022 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/computer-architecture/program-exec-mental-model/</guid><description>&lt;p&gt;This post is about my mental model of program execution based on the building blocks of computer—logical functions.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Every bit of magic in computer science starts from logical gates.&lt;/p&gt;&#10;&lt;h3 id="logical-function"&gt;Logical function&lt;/h3&gt;&#10;&lt;p&gt;A function is a many-to-one relation. Each function has an &lt;strong&gt;input&lt;/strong&gt; (domain) and an &lt;strong&gt;output&lt;/strong&gt; (converse domain).&lt;/p&gt;</description></item><item><title>Operational System Overview</title><link>https://hbisheng.github.io/blogs/operating-system/operating-system-overview/</link><pubDate>Tue, 04 Oct 2022 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/operating-system/operating-system-overview/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; OS is a &lt;strong&gt;system program&lt;/strong&gt; that provides a curated environment for user programs to run.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;Think about all the physical aspects of running a program in reality, everything that is not written in the user program is handled by the OS.&lt;/p&gt;</description></item><item><title>Network: Socket and the network stack</title><link>https://hbisheng.github.io/blogs/network/blog-001/</link><pubDate>Sat, 01 Oct 2022 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/network/blog-001/</guid><description>&lt;p&gt;&lt;em&gt;Q: I have two programs running on two different computers. How do they talk to each other through the network?&lt;/em&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Socket is an abstraction provided by the operating system for network communication.&lt;/p&gt;</description></item><item><title>Orchestration Platform</title><link>https://hbisheng.github.io/blogs/infrastructure/orchestration-platform/</link><pubDate>Mon, 29 May 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/infrastructure/orchestration-platform/</guid><description>&lt;p&gt;An orchestration platform is faced with the following task: You are given a number of (e.g. 10K) physical machines. Your users want you to run their services; they specify certain resource requirements but other than that do not care where the service will run. Now you have to figure things out.&lt;/p&gt;</description></item><item><title>Transaction Isolation Levels</title><link>https://hbisheng.github.io/blogs/database/transaction-isolation-levels/</link><pubDate>Sun, 26 Mar 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/database/transaction-isolation-levels/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Transaction isolation levels define the permitted behaviors of a system when concurrent transactions are executed.&lt;/p&gt;&#10;&lt;h2 id="background"&gt;Background&lt;/h2&gt;&#10;&lt;p&gt;What&amp;rsquo;s a transaction? A &lt;strong&gt;transaction&lt;/strong&gt; is a group of operations (possibly operating on multiple data items) that either succeeds as a whole (commit) or fails as a whole (abort). There&amp;rsquo;s no state of partial success or partial failure. Transactions allow application developers to focus on the correctness of operations within a transaction and worry less about the existence of concurrent operations. The &lt;strong&gt;serializability&lt;/strong&gt; isolation level maintains the illusion that there&amp;rsquo;s no concurrent transaction execution at all.&lt;/p&gt;</description></item><item><title>CPU &lt;-&gt; memory interaction</title><link>https://hbisheng.github.io/blogs/computer-architecture/cpu-mem/</link><pubDate>Mon, 06 Feb 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/computer-architecture/cpu-mem/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; CPU interacts with the main memory on the motherboard using the BUS protocol. There is a hierarchy of CPU caches (L1, L2, L3) between them.&lt;/p&gt;&#10;&lt;p&gt;We talked about the CPU and main memory as separate components. In this post, we&amp;rsquo;ll look further into how they interact.&lt;/p&gt;</description></item><item><title>Building logic gates from transistors</title><link>https://hbisheng.github.io/blogs/hardware-physics/logic-gates-from-transistors/</link><pubDate>Fri, 13 Jan 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/hardware-physics/logic-gates-from-transistors/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Transistors manipulate voltage levels to build logic gates.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;Transistors can be used to build logic gates.&lt;/p&gt;&#10;&lt;h2 id="logic-gate"&gt;Logic Gate&lt;/h2&gt;&#10;&lt;p&gt;What&amp;rsquo;s a &lt;strong&gt;logic gate&lt;/strong&gt; in the first place? Not worrying about the official definition, I think of a logic gate as a device that takes several input signals and produces one output signal. They are the logical building blocks of computers.&lt;/p&gt;</description></item><item><title>Network protocol: Ethernet</title><link>https://hbisheng.github.io/blogs/network/ethernet-protocol/</link><pubDate>Sat, 05 Nov 2022 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/network/ethernet-protocol/</guid><description>&lt;p&gt;This post describes the &lt;strong&gt;Ethernet protocol&lt;/strong&gt;, a common protocol that serves as the &lt;strong&gt;physical layer&lt;/strong&gt; and the &lt;strong&gt;data link layer&lt;/strong&gt; in the &lt;strong&gt;network stack&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; The Ethernet protocol allows devices connected through a cable to communicate.&lt;/p&gt;</description></item><item><title>Computer startup process</title><link>https://hbisheng.github.io/blogs/operating-system/computer-startup-process/</link><pubDate>Tue, 04 Oct 2022 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/operating-system/computer-startup-process/</guid><description>&lt;p&gt;With a &lt;a href="https://hbisheng.github.io/blogs/computer-architecture/program-exec-mental-model/"&gt;mental model of program execution&lt;/a&gt; in mind, what happens when you turn on your computer?&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Read-only memory (ROM) on the mainboard is always available for read once the power is on.&lt;/li&gt;&#10;&lt;li&gt;Once power is plugged in, CPU starts executing instructions from ROM. The first program is BIOS.&lt;/li&gt;&#10;&lt;li&gt;BIOS performs &lt;strong&gt;Power On Self Test (POST)&lt;/strong&gt; which checks that necessary hardware devices are present.&lt;/li&gt;&#10;&lt;li&gt;BIOS finds the &lt;strong&gt;boot drive&lt;/strong&gt; (the hard disk) and starts the &lt;strong&gt;bootloader&lt;/strong&gt; program.&lt;/li&gt;&#10;&lt;li&gt;The &lt;strong&gt;bootloader&lt;/strong&gt; loads the &lt;strong&gt;operating system&lt;/strong&gt; image (its programs and data) into memory.&lt;/li&gt;&#10;&lt;li&gt;The operating system takes control.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Now let&amp;rsquo;s dive into the &lt;a href="https://hbisheng.github.io/blogs/operating-system/operating-system-overview/"&gt;operating system&lt;/a&gt;—the first piece of system software.&lt;/p&gt;</description></item><item><title>Operational Management</title><link>https://hbisheng.github.io/blogs/infrastructure/operational-management/</link><pubDate>Mon, 03 Jul 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/infrastructure/operational-management/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Use a workflow platform (e.g. Cadence, Amazon Step Functions) to manage your operations.&lt;/p&gt;&#10;&lt;p&gt;In the last post, we talk about the convergence loop as a process that performs operations to converge the actual states with the target states. Let&amp;rsquo;s take a closer look at operations. Operations change the state of the system. Operational management is about managing the ways of doing operations on your platform.&lt;/p&gt;</description></item><item><title>Datastore design: B+ tree and LSM tree</title><link>https://hbisheng.github.io/blogs/database/datastore-design/</link><pubDate>Mon, 03 Apr 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/database/datastore-design/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; B+ tree was the dominating data structure for database indexing. The LSM tree has become increasingly popular in the distributed database world. Let&amp;rsquo;s consider building an &lt;strong&gt;OLTP (online transactional processing)&lt;/strong&gt; data store from scratch.&lt;/p&gt;</description></item><item><title>CPU scheduling/throttling</title><link>https://hbisheng.github.io/blogs/operating-system/cpu-scheduling/</link><pubDate>Wed, 15 Feb 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/operating-system/cpu-scheduling/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; The operating system controls when and how long processes run on the CPUs.&lt;/p&gt;&#10;&lt;h2 id="background"&gt;Background&lt;/h2&gt;&#10;&lt;p&gt;A &lt;strong&gt;program&lt;/strong&gt; is a static sequence of instructions. When it is being executed, it becomes a &lt;strong&gt;process&lt;/strong&gt; managed by the operating system. The operating system controls which processes have access to the CPU at a given point in time.&lt;/p&gt;</description></item><item><title>CPU hyperthreading</title><link>https://hbisheng.github.io/blogs/computer-architecture/hyperthreading/</link><pubDate>Fri, 10 Feb 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/computer-architecture/hyperthreading/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Hyperthreading turns a physical core into multiple logical cores and allows starting multiple instructions per cycle. But it can not achieve the same performance as having real physical cores due to shared resources (e.g. CPU caches).&lt;/p&gt;</description></item><item><title>DRAM under the hood (transistors and capacitors)</title><link>https://hbisheng.github.io/blogs/hardware-physics/dram/</link><pubDate>Sat, 14 Jan 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/hardware-physics/dram/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; DRAM stores data in billions of memory cells where each cell has a transistor and a capacitor.&lt;/p&gt;&#10;&lt;p&gt;In our mental model of program execution, we imagined the memory of a computer to be built from &lt;strong&gt;logical gates&lt;/strong&gt;. That&amp;rsquo;s not entirely accurate. It&amp;rsquo;s true that registers are built from D flip flops which are based on logical gates. But those memories are relatively small.&lt;/p&gt;</description></item><item><title>Network protocol: IP</title><link>https://hbisheng.github.io/blogs/network/network-protocol-ip/</link><pubDate>Tue, 13 Dec 2022 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/network/network-protocol-ip/</guid><description>&lt;p&gt;&lt;strong&gt;Main Thread:&lt;/strong&gt; Logical gates → Registers → Program execution (memory and CPU) → Operating system → Intercommunication through Ethernet → Routing protocols in a network&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; The IP protocol routes data packets around the world.&lt;/p&gt;</description></item><item><title>Stream Processing</title><link>https://hbisheng.github.io/blogs/infrastructure/stream-processing/</link><pubDate>Tue, 04 Jul 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/infrastructure/stream-processing/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; A stream is an unbounded sequence of events with producers and consumers. It&amp;rsquo;s a rich source of data that can be utilized for diverse applications like asynchronous event processing, analytics, etc. Kafka is a prominent stream-processing service.&lt;/p&gt;</description></item><item><title>MySQL and InnoDB</title><link>https://hbisheng.github.io/blogs/database/mysql-and-innodb/</link><pubDate>Mon, 22 May 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/database/mysql-and-innodb/</guid><description>&lt;h2 id="intro"&gt;Intro&lt;/h2&gt;&#10;&lt;p&gt;&lt;strong&gt;Relational database:&lt;/strong&gt; MySQL is a relational database. In a relational database, all data is organized in the shape of a &lt;strong&gt;table&lt;/strong&gt;,with &lt;strong&gt;rows&lt;/strong&gt; and &lt;strong&gt;columns&lt;/strong&gt;. The first row can be thought of as the header. Similar to a table in its common sense, the header describes what information will be present for each row in the table; the header forms the &lt;strong&gt;schema&lt;/strong&gt; of the table. Each row is a data point; each column is a property of that data point.&lt;/p&gt;</description></item><item><title>System Calls</title><link>https://hbisheng.github.io/blogs/operating-system/system-calls/</link><pubDate>Fri, 17 Feb 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/operating-system/system-calls/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; User programs issue system calls to use the services provided by the operating system. Such services include interacting with the hardware devices.&lt;/p&gt;&#10;&lt;p&gt;The operating system is the interface between a user program and the hardware devices. The OS provides services to the user programs. The services are provided through &lt;strong&gt;system calls&lt;/strong&gt;. To use hardware resources, users programs invoke system calls.&lt;/p&gt;</description></item><item><title>NUMA and cache coherence protocols</title><link>https://hbisheng.github.io/blogs/computer-architecture/multi-core-cpu/</link><pubDate>Mon, 13 Feb 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/computer-architecture/multi-core-cpu/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Modern CPUs have multiple cores and multiple memory banks. Different cores have their own cache and they adopt a cache coherence protocol to maintain memory coherence.&lt;/p&gt;&#10;&lt;p&gt;This &lt;a href="https://www.youtube.com/playlist?list=PLeWkeA7esB-OgNoVkE2lW2cVBxpDbu92h"&gt;series of videos&lt;/a&gt; is very helpful in building an understanding of multicore architectures.&lt;/p&gt;</description></item><item><title>Disks basics (HDD and SSD)</title><link>https://hbisheng.github.io/blogs/hardware-physics/disks/</link><pubDate>Sun, 15 Jan 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/hardware-physics/disks/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; HDD stores data in spinning disks with magnified regions. SSD stores data in charge traps; it writes in pages and erases in blocks.&lt;/p&gt;&#10;&lt;p&gt;DRAMs or registers are considered &lt;strong&gt;volatile memory&lt;/strong&gt;; the information gets lost when unplugged from power. We need &lt;strong&gt;non-volatile memory&lt;/strong&gt; to persist and store data for the long term. The two common kinds of non-volatile memory are HDD and SSD. We&amp;rsquo;ll cover some basics of it.&lt;/p&gt;</description></item><item><title>Network: LAN and WAN</title><link>https://hbisheng.github.io/blogs/network/lan-wan/</link><pubDate>Sat, 17 Dec 2022 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/network/lan-wan/</guid><description>&lt;p&gt;&lt;strong&gt;Main Thread:&lt;/strong&gt; Logical gates → Registers → Program execution (memory and CPU) → Operating system → Intercommunication through Ethernet → Routing protocols in a network → IP protocol at different scales&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; The IP protocol allows different kinds of networks to interconnect.&lt;/p&gt;</description></item><item><title>What I know about Redis</title><link>https://hbisheng.github.io/blogs/database/redis/</link><pubDate>Sat, 08 Apr 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/database/redis/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Redis is an in-memory data store that supports many kinds of data structures.&lt;/p&gt;&#10;&lt;p&gt;Redis is a datastore written in C. It is a TCP server that waits for client requests.&lt;/p&gt;&#10;&lt;p&gt;Redis offers multiple data structures for storing the data, including string, list, hash map, and sorted set. The APIs are rich and powerful which enables all kinds of use cases. Redis is a good fit when your data fits into memory and &lt;strong&gt;durability is not required&lt;/strong&gt;. Redis provides speedy access to the data structures, and manages them with bounded memory, allowing you to configure an eviction policy, e.g. LRU, LFU. &lt;strong&gt;Caching&lt;/strong&gt; is a good use case and probably the most common one.&lt;/p&gt;</description></item><item><title>File system</title><link>https://hbisheng.github.io/blogs/operating-system/filesystem/</link><pubDate>Mon, 20 Feb 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/operating-system/filesystem/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; A filesystem organizes the information on disks to support reading and writing a large number of files.&lt;/p&gt;&#10;&lt;p&gt;Information that needs to be persisted is stored on the disk. You want to store a lot of data in it, which requires you to organize the information well. In disks, the space is divided into pages. The interface provided by the hardware disks can be simplified as two APIs:&lt;/p&gt;</description></item><item><title>Network protocol: TCP</title><link>https://hbisheng.github.io/blogs/network/tcp/</link><pubDate>Sun, 01 Jan 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/network/tcp/</guid><description>&lt;p&gt;&lt;strong&gt;Main Thread:&lt;/strong&gt; Logical gates → Registers → Program execution (memory and CPU) → Operating system → Intercommunication through Ethernet → Routing protocols in a network → IP protocol at different scales → TCP layer&lt;/p&gt;</description></item><item><title>Definitions of software and hardware</title><link>https://hbisheng.github.io/blogs/computer-architecture/software-vs-hardware/</link><pubDate>Sat, 05 Nov 2022 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/computer-architecture/software-vs-hardware/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Software is instruction. Hardware is the physical material that takes instructions.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;What is &lt;strong&gt;software&lt;/strong&gt; and what is &lt;strong&gt;hardware&lt;/strong&gt;? Here is a basic non-formal definition for myself:&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Hardware&lt;/strong&gt; are the physical devices in the physical world. They are atoms arranged in a way that achieve certain functionalities.&lt;/p&gt;</description></item><item><title>Raft</title><link>https://hbisheng.github.io/blogs/database/raft/</link><pubDate>Sat, 11 Mar 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/database/raft/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Raft is a protocol for distributed consensus. It&amp;rsquo;s a strong leader protocol where the leader forces the followers to have the same log entries. Only an up-to-date candidate can be elected which guarantees that a committed entry is contained in all future leaders.&lt;/p&gt;</description></item><item><title>Paging, Page Cache</title><link>https://hbisheng.github.io/blogs/operating-system/paging/</link><pubDate>Mon, 20 Feb 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/operating-system/paging/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Data is moved between disks and memory in pages. The OS maintains the illusion that each process has its own virtual memory space and translates a virtual address into a physical one with the help of the page directory and page tables. The OS has kernel-level page caches for files.&lt;/p&gt;</description></item><item><title>Network Protocol: BGP</title><link>https://hbisheng.github.io/blogs/network/bgp/</link><pubDate>Mon, 02 Jan 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/network/bgp/</guid><description>&lt;p&gt;&lt;strong&gt;Main Thread:&lt;/strong&gt; Logical gates → Registers → Program execution (memory and CPU) → Operating system → Ethernet → Routing protocols → IP protocol at different scales → TCP → BGP protocol&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; BGP is the routing protocol for the Internet. BGP peers across different autonomous systems exchanges full routing paths to destinations.&lt;/p&gt;</description></item><item><title>Paxos</title><link>https://hbisheng.github.io/blogs/database/paxos/</link><pubDate>Sat, 11 Mar 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/database/paxos/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Paxos is a protocol for distributed consensus. In its simplest form, a group of participants collectively decide and agree on a single value of the system.&lt;/p&gt;&#10;&lt;p&gt;The problem in general was discussed in the &lt;a href="https://hbisheng.github.io/blogs/database/raft/"&gt;Raft post&lt;/a&gt;. We&amp;rsquo;ll be talking about single-decree Paxos where a group of participants want to decide on a single value. A value can be considered as a log entry—an event that leads to state changes. Single-decree Paxos can be repeated to decide on multiple values, forming a log.&lt;/p&gt;</description></item><item><title>Memory Management</title><link>https://hbisheng.github.io/blogs/operating-system/memory-management/</link><pubDate>Mon, 20 Feb 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/operating-system/memory-management/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; The OS is responsible for managing the memory, including allocation, deallocation, defragmentation, and reclaim.&lt;/p&gt;&#10;&lt;h2 id="memory-allocation"&gt;Memory allocation&lt;/h2&gt;&#10;&lt;p&gt;&lt;strong&gt;Buddy system&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Maintain a list of free blocks.&lt;/li&gt;&#10;&lt;li&gt;Allocation&#10;&lt;ul&gt;&#10;&lt;li&gt;Choose the smallest possible block during allocation. Split the memory block if the allocation takes less than half of the block. Say you have one block of 16KB and the user requests a block of 4KB, you end up with two free blocks: 4KB and 8KB.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;Deallocation&#10;&lt;ul&gt;&#10;&lt;li&gt;When a block is freed, if its buddy (the node that shares the same parent) is also free, they can be merged into a larger free node.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;The buddy system reduces fragmentation to some degree. At least smaller blocks can be merged at times to serve larger requests.&lt;/p&gt;</description></item><item><title>Network: DNS</title><link>https://hbisheng.github.io/blogs/network/dns/</link><pubDate>Tue, 03 Jan 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/network/dns/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; DNS converts domain names into IP addresses.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;Let&amp;rsquo;s say the Internet is out there. There are websites of different kinds waiting for you to visit. And there are so many of them. Theoretically, each website can just be identified by an IP address, a 32-bit number. But human minds are not so good at remembering such numbers. You don&amp;rsquo;t remember all the phone numbers of your friends. Your phone maintains a phonebook (a contact list) so you can just look up the phone number by a certain person&amp;rsquo;s name.&lt;/p&gt;</description></item><item><title>Etcd</title><link>https://hbisheng.github.io/blogs/database/etcd/</link><pubDate>Sun, 12 Mar 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/database/etcd/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Etcd is a distributed MVCC key-value store that implements the Raft protocol. It&amp;rsquo;s wildly used in distributed coordination, such as storing system configurations (e.g. Kubernetes).&lt;/p&gt;&#10;&lt;h2 id="background"&gt;Background&lt;/h2&gt;&#10;&lt;p&gt;&lt;a href="https://etcd.io/docs/v3.5/tutorials/"&gt;https://etcd.io/docs/v3.5/tutorials/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;With Raft, etcd maintains a replication log where each entry is a mutative operation. The operations are committed to Boltdb, a persistent storage engine using B+ tree. The revision concept in etcd:&lt;/p&gt;</description></item><item><title>Network: CDN</title><link>https://hbisheng.github.io/blogs/network/cdn/</link><pubDate>Tue, 03 Jan 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/network/cdn/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; CDN (content delivery network) speeds up the delivery of static content by putting it as close to the users as possible.&lt;/p&gt;&#10;&lt;h3 id="cdn"&gt;CDN&lt;/h3&gt;&#10;&lt;p&gt;Videos and images consist of lots of bits and can be slow to load. To speed up the delivery of those static contents, a CDN deploys a large number of geographically distributed servers and uses the server closet to the user to serve its request.&lt;/p&gt;</description></item><item><title>Cassandra notes</title><link>https://hbisheng.github.io/blogs/database/cassandra-notes/</link><pubDate>Mon, 22 May 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/database/cassandra-notes/</guid><description>&lt;p&gt;Cassandra is a leaderless distributed key-value database.&lt;/p&gt;&#10;&lt;p&gt;Cassandra does not support &lt;strong&gt;secondary indexes&lt;/strong&gt;. It does support &lt;strong&gt;range queries&lt;/strong&gt; for data on a particular node (things are always easy when the data is colocated; it&amp;rsquo;s hard when the data is distributed).&lt;/p&gt;</description></item><item><title>TLA+</title><link>https://hbisheng.github.io/blogs/database/tla-plus/</link><pubDate>Fri, 10 Mar 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/database/tla-plus/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; TLA+ is a language used for &lt;strong&gt;specifying&lt;/strong&gt; concurrent and distributed systems**.** It&amp;rsquo;s useful for finding flaws in your high-level system design, before writing a single line of code. It&amp;rsquo;s a tool of math or logic.&lt;/p&gt;</description></item><item><title>Network: TLS</title><link>https://hbisheng.github.io/blogs/network/tls/</link><pubDate>Tue, 03 Jan 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/network/tls/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; TLS (Transport Layer Security) is a network security protocol that uses cryptographic algorithms involving pairs of keys (private and public) to secure network communications.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;When you talk to google.com, how do you know the response you receive is sent from a legit server?&lt;/p&gt;</description></item><item><title>Network Protocol: HTTP, Websocket</title><link>https://hbisheng.github.io/blogs/network/http/</link><pubDate>Wed, 04 Jan 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/network/http/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; HTTP (Hyper-Text Transfer Protocol) is an application layer protocol that enables you to browse websites.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;We&amp;rsquo;ve covered most of the fundamentals such as routing, transport, and security, now it&amp;rsquo;s finally time to look at some applications! One of the most popular activities on the internet is visiting websites. You type in a domain name and your browser will display you web pages. The data format of the underlying web content is HTML (Hyper-text Mark-up Language). HTTP is the protocol that transmits HTML from the web server to your browser.&lt;/p&gt;</description></item></channel></rss>