A reading room for engineers

System design notes

What happens when the cache is stale, the queue repeats a message, or every buyer wants the same seat? Work through the decisions, one note at a time.

01

Placing data

  1. 01.01 Adding a shard without moving everything A hash ring narrows the set of keys that must move. It still leaves you with a migration to run.
  2. 01.02 The index starts with the query A composite index is useful when its key order matches the rows one request needs to walk.
02

Serving traffic

  1. 02.01 The cache was invalidated. Then an old value came back. A delete event can win the race and still leave stale data in the cache.
  2. 02.02 The bucket has tokens. The service is still overloaded. Burst allowance, sustained rate and work already in flight protect different limits.
  3. 02.03 The socket only carries the live edge Own each connection on one gateway, bound its backlog, and recover missed events from durable history.
03

Surviving failure

  1. 03.01 The payment timed out. Did it go through? Keep the identity of an operation separate from the request that happened to carry it.
  2. 03.02 A queue hands work to a worker. A log lets you replay it. Redelivery recovers one unfinished task; replay rebuilds a consumer from retained history.
  3. 03.03 The payment arrived after the seat hold expired One database invariant must decide who owns the seat when clocks and callbacks disagree.