skip to content
17, 10 chapters
scale and distribution

scale and distribution

pools, partitions, replicas, shards, and what changes when the data no longer fits on one machine.

start part 17part 17 of 18, 10 chapters
  1. 17.01connections and poolinga process per connection, why 5,000 connections hurt, and pgbouncer's three modes.
  2. 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.
  3. 17.03table partitioningrange, list and hash partitions, pruning at plan and run time, and the key every unique index must include.
  4. 17.04read replicas and read-your-writessending reads to a standby, the stale read right after a write, and waiting for an LSN.
  5. 17.05shardingone table across many machines. shard keys, hot shards, and the query that has to ask everyone.
  6. 17.06CAP and PACELCthe theorem everyone quotes wrong, and the latency trade-off that matters on a normal day.
  7. 17.07consistency modelslinearizable, serializable, causal, eventual. a map of what distributed databases actually promise.
  8. 17.08two-phase commitprepare everywhere, then commit everywhere. PREPARE TRANSACTION, and the coordinator that dies at the worst moment.
  9. 17.09replication and consensusleaders, terms and a replicated log. raft in pictures, and why it needs a majority.
  10. 17.10distributed SQL and disaggregated storagespanner, cockroachdb, citus, aurora and neon. how each one splits the problem.