17, 10 chapters
scale and distribution
everything.scale
scale and distribution
pools, partitions, replicas, shards, and what changes when the data no longer fits on one machine.
- 17.01connections and poolinga process per connection, why 5,000 connections hurt, and pgbouncer's three modes.
- 17.02ORMs and the N+1 problemone query for the list, one per row for the details. spotting it, and fixing it with a join.
- 17.03table partitioningrange, list and hash partitions, pruning at plan and run time, and the key every unique index must include.
- 17.04read replicas and read-your-writessending reads to a standby, the stale read right after a write, and waiting for an LSN.
- 17.05shardingone table across many machines. shard keys, hot shards, and the query that has to ask everyone.
- 17.06CAP and PACELCthe theorem everyone quotes wrong, and the latency trade-off that matters on a normal day.
- 17.07consistency modelslinearizable, serializable, causal, eventual. a map of what distributed databases actually promise.
- 17.08two-phase commitprepare everywhere, then commit everywhere. PREPARE TRANSACTION, and the coordinator that dies at the worst moment.
- 17.09replication and consensusleaders, terms and a replicated log. raft in pictures, and why it needs a majority.
- 17.10distributed SQL and disaggregated storagespanner, cockroachdb, citus, aurora and neon. how each one splits the problem.