Chapter Deep Read · Database Internals · Ch 8

Introduction and Overview: Distributed Systems

Database Internals · Ch 8 · Alex Petrov · 2019

中文 →

What is this chapter about?

You tap "Confirm payment" on your phone. That message crosses a cell tower, some fiber, and several machines in a data center before it lands in a database. The first seven chapters were all about what happens inside one machine. From here on the stage changes: many machines, and the only way they can cooperate is by shouting at each other. This chapter teaches no technique. It tells you which things, on that stage, are impossible in principle.

A strange thing first

You text a friend "does 8pm work?" and ten minutes pass with no reply. Maybe the message never arrived. Maybe they replied and the reply got lost. Maybe they are typing right now. From the outside, all three look exactly the same. That indistinguishability is the sharpest edge in distributed systems: when something times out, you do not know whether the other side is dead, slow, or simply had its answer eaten on the way back.

Why the old world was easier

On a single machine, three things come for free: call a function and it will return; read a variable and you get the latest value; glance at the clock and time always moves forward. Across two machines, none of the three survives. A function call becomes "mail a letter and maybe never hear back". "The latest value" becomes "the last thing I heard". And the two clocks may drift seconds apart.

How it actually works

The chapter's move is not to hand you a cure. It is to pin down the vague parts, turning "the network is flaky" into three written-down assumption tables that every later algorithm is designed against:

So what do you pick

Stronger promises cost more. The clearest case is "delivered exactly once, no more, no less" — that one is unachievable at the wire level: when the sender sees a failure, it can never tell "never arrived" from "arrived, was processed, and the receipt got lost". What you can actually do is send several times and let the recipient de-duplicate by tracking number. Payment idempotency keys and message-queue dedup tables are all instances of that one rule.

The honest cost: these three tables buy you the ability to say why your design is correct, not reliability itself. Assume too little and no algorithm can run; assume too much and one bad day in the real world takes the whole thing down.

One line to remember

Distributed systems are hard not because there are many machines, but because nobody can see "now". Every machine holds only a stale rumor. The one thing engineering can do is nail down how reliable the link is, how trustworthy the clock is, and how nodes break — and only then start building on top.

Want the mechanisms, the notation and the diagrams? → Switch to the deep read