← All Chapters
15 topics

Systems and Networking

Caches, load balancers, shards and packets, the machinery behind every request.

  1. 46Network Stack and RoutingWalk a packet through two switched networks joined by a router and watch the layer 2 header get rewritten at the crossing while the layer 3 addresses ride through unchanged
  2. 47ReplicationOne primary, two lagging replicas, and what a failover loses
  3. 48CachingFeed a fixed request stream through a real least-recently-used cache of three slots and watch hits skip the slow origin while each miss fetches a key and evicts the one used longest ago
  4. 49Where Caches Live: Browser to DatabaseWatch reads fall through a browser cache, a CDN, and Redis before the database answers, each answer copied back up the stack until the warmed layers catch almost everything
  5. 50Percentiles and Tail LatencyDrag a percentile handle across a fixed sample of 60 request latencies and watch the mean sit far below p99, because a handful of slow tail requests drag the average up while most requests never see them
  6. 51Load BalancingSend one fixed request stream through a balancer to three servers and watch round robin pile long requests onto one server while least connections keeps them level, then kill a server mid-run and see which policy copes
  7. 52CAP TheoremReplicate one key across two nodes, cut the network between them, and choose: refuse writes to stay consistent or serve both sides and let the copies diverge, the tradeoff a partition forces
  8. 53ShardingPick a partition key and watch rows hash into shards, then see a low-cardinality key pile most rows onto one hot shard
  9. 54Consistent HashingPlace keys on a hash ring, then add a node and watch only a small slice of keys move, while plain hash-mod-N would reshuffle almost everything
  10. 55Race Conditions and LocksStep two threads through a shared balance by hand or on auto-play, watch a bad interleaving lose an update, then turn on a lock and try to break it again
  11. 56DeadlockTwo threads, two locks, grabbed in opposite orders, and watch the wait-for graph close into a circular deadlock, then switch to one lock order and see it become impossible
  12. 57TCP and UDPSend the same 8 packets across an identical lossy channel and watch UDP finish fast with permanent gaps while TCP detects each drop, resends it, and holds arrivals out of order until the gap behind them fills in
  13. 58DNSResolve a name through root, TLD, and authoritative servers, watching each one hand back a referral instead of an answer, then look it up again and watch the cached answer skip the whole chain
  14. 59Encryption and Public KeysLock a message with someone's public key and see that only their private key opens it, then flip the keys to sign
  15. 60Streaming and BufferingWatch a playback buffer fill from a variable network and drain at a steady rate, then drop the network speed and see the stall coming before it happens