Unit 10 of 13 · about 4 hours · explain, measure
Connection pools, load balancing, health and HTTP/3 transport behavior
Pools and balancers decide which server pays for each call. An exhausted pool or a naive balancer turns one slow replica into a system-wide stall.
You'll be able to
- Explain pool sizing, checkout timeouts and exhaustion signals, and graceful drain on shutdown.
- Contrast layer-4 versus layer-7 balancing, health checking and the cost of affinity.
- Explain QUIC streams, migration and HTTP/3 mapping at review depth without implementing them.
Covers
Read
In this order, only the parts listed
0 of 3 done
- HLD load balancers and networking fundamentalsHLD Handbook - Networking, API Design and Backpressure
Load Balancers: layer-4 5-tuple versus layer-7 routing, health checks and affinity; plus the Networking Fundamentals chapter for TCP versus UDP and HTTP/1.1 through HTTP/3 head-of-line blocking
- gRPC keepalive guidegRPC Guides - Deadlines, Cancellation, Status Codes, Retry and Flow Control
Overview and configuration table: HTTP/2 PING keepalives, client default disabled, server default 2 hours, 20 s timeout,
too_many_pingsGOAWAY on abuse; clients should not set keepalive much below one minute and must agree settings with the service owner - RFC 9000 QUIC transport behaviorRFC 9000 - QUIC Version 1
Section 2 Streams with independent stream states, Section 4 Flow Control per stream and connection, Section 9 Connection Migration; HTTP/3 mapping in RFC 9114 Sections 3, 6 and 7
Review only for the optional QUIC topic. Read the cited sections and compare with TCP head-of-line blocking; do not implement QUIC.
Focus on
- The Systems unit on connection shutdown, pools and latency decomposition sized pools with Little's law. Here the new work is the caller's side under failure: checkout timeouts and exhaustion as a fast explicit error, never an unbounded wait, plus health gating and the balancer's choice.
- Layer-4 balancers forward bytes by 5-tuple; layer-7 balancers parse requests and can route, shed and retry per call. Affinity buys cache warmth and pays with hot replicas.
- Health checking is about the service, keepalive about the connection. A live TCP connection to a sick service still needs a health-gated balancer decision.
- QUIC runs over UDP and does its own loss recovery, usually in a user-space library: independent streams avoid TCP head-of-line blocking, and connection IDs survive address changes via migration.
Common mistakes · 3
- Sizing pools by server count. Size by arrival rate times hold time plus headroom, with checkout timeouts; an infinite wait on checkout is a distributed deadlock.
- Reading affinity as load balancing. Sticky routing concentrates load and failure, so use it only where cache or state locality pays, with a rebalance path.
- Enabling aggressive keepalive unilaterally. The server treats ping floods as abuse and sends
too_many_pingsGOAWAY; coordinate intervals with owners.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Checkout waits grow while server latency is flat. What is exhausted?Answer
The client pool, not the server. All connections are checked out, so new calls queue at checkout; surface a fast error and fix sizing or downstream fan-out.
2.Why is a health check not redundant with TCP keepalive?Answer
Keepalive proves the connection is alive. Health proves the service behind it can serve; a hung handler on a live connection needs health gating to drain.
3.What do the gRPC keepalive defaults say about who pays?Answer
Clients default to disabled and servers to 2-hour intervals with 20 s timeouts. Frequent client pings cost the server, so they need explicit agreement.
4.A client changes Wi-Fi networks mid-download. Why does QUIC survive where TCP restarts?Answer
QUIC identifies the connection by ID, not by address tuple, and Section 9 migration revalidates the new path. TCP binds to the tuple, so the new address is a new connection.
Practice
- Building Distributed Systems: TC-2 pool and TC-3 drain
TC-2 connection pool with backlog, TC-3 graceful shutdown with in-flight drain; both are in the free first three Networker tasks
Tasks are graded in the browser after login, so treat a pass as a drill and keep your pool-exhaustion and drain-timing measurements as the evidence.
- Design a Least Requests Load Balancer
Implement
acquireleast-loaded with smallest-index tie-break andreleasefloored at zeroThe judge checks routing logic only. Add health gating and an affinity-cost comparison in your own harness.
You're done when
You can size a pool from arrival rate and hold time, predict the balancer move for one failure, and state the QUIC stream and migration differences without claiming production QUIC operation.
Only when you can do this without notes.
Leads to
Notes
Resources · 3 for this unit, 13 more in the section
- gRPC Guides - Deadlines, Cancellation, Status Codes, Retry and Flow ControlgRPC Authors · required
Read the deadlines, cancellation, status codes, retry (enabled by default with no default policy; no retry once response headers arrive), keepalive and flow-control guides. Turn each into a rule your own RPC layer follows, and check a claim against grpcio before you rely on it.
- HLD Handbook - Networking, API Design and BackpressureHLD Handbook · required
Read only Part 0 networking and API design, then the load balancer, service discovery, rate limiting and reliability chapters needed for the protocol design. Use the diagrams to review boundaries, not as a substitute for fault tests.
- RFC 9000 - QUIC Version 1IETF · reference
Read Section 2 (streams), Section 4 (flow control) and Section 9 (connection migration) for QUIC transport behavior. No implementation; compare with TCP behavior from the Systems stage.
Also in this section
- DDIA 2e - Chapter 5 Encoding and EvolutionMartin Kleppmann and Chris Riccomini · primary
Read formats, schema evolution, service RPC, durable workflows and event-driven dataflow. Write a four-version compatibility table and connect each compatibility claim to a wire fixture.
- Protocol Buffers and Avro - Unknown Fields and Schema ResolutionGoogle and the Apache Software Foundation · required
Read the proto3 guide on field numbers, defaults and unknown fields (kept through binary parsing and reserialization, lost through JSON) and the Avro 1.12.0 schema resolution rules (https://avro.apache.org/docs/1.12.0/specification/). Build round-trip fixtures that show each rule.
- Building Distributed Systems - The MessengerBuild Distributed Systems · support
Track 1 is free: do the RPC subtrack (sync RPC with timeout, timeout and retry loop, async callbacks, callback reaper, exponential backoff) and the deduplication task. Tasks are graded in the browser after login, so treat a pass as a drill and keep your local harness as the evidence.
- MIT 6.5840 - RPC and Threads plus Lab 2 Key/Value ServerMIT PDOS · required
Read the Lecture 2 notes (
notes/l-rpc.txtandnotes/kv.go) on RPC failure and at-most-once execution, then do Lab 2: a versionedPutkey/value server whose client returnsErrMaybewhen a retriedPutmay already have run, and a lock built on it. Keep the course tests, then add cancellation, size-limit and mixed-version faults in your own harness. - DSLabs - Lab 1 Exactly-Once RPCUniversity of Washington (Ellis Michael) · support
Labs are Java 21 message-passing state machines tested on an emulated network and by model-checking search tests that print a minimal violating trace; run them with the
run-tests.pyscript and its--laband--partoptions. Lab 1 builds an "exactly-once" RPC abstraction for an unreplicated key/value server on a network that drops, duplicates and reorders messages. Use it to check your request identity and duplicate-suppression design against exhaustive orderings. - AWS Builders' Library - Timeouts, Retries and Backoff with JitterAmazon Web Services · required
Read the whole article for timeout choice, retries at one layer, retry amplification across hops, capped exponential backoff and jitter. Derive the request multiplier for retries at every layer of a call chain before writing your retry policy.
- AWS Builders' Library - Making Retries Safe with Idempotent APIsAmazon Web Services · support
Read the caller-provided client request identifier pattern, the validation error for a repeated identifier with different parameters, the semantically equivalent response to a retry and why the identifier is retained only for a bounded interval. Compare that interval with your own duplicate-suppression state.
- Building Distributed Systems - The NetworkerBuild Distributed Systems · optional
Only the first three tasks are free (TCP echo, connection pool and backlog, graceful shutdown and drain). Tasks are graded in the browser after login, so treat a pass as a drill and keep your local harness as the evidence.
- Beej's Guide to Network ProgrammingBrian Hall · support
Use the client, server, send, receive, select or poll, and partial-transfer sections when socket behavior is unclear. This is a protocol mechanics reference, not the distributed-systems spine.
- AlgoMaster System Design - Selected Networking and API ProblemsAlgoMaster · optional
Use the problems on idempotency and retries (Deduplicate Idempotent Requests, Build an Idempotent Consumer, Classify Retry Outcomes), rate limiting (sliding-window log and token bucket), the Least Requests load balancer and the queue visibility timeout. For every solved component, add an external fault test and explain what its simplified judge does not establish.
- Replicated Log and Stream Processor - Protocol SliceRoadmap-Final · support
Create the repository, message schema, request and node identities, deadline and retry contract, deterministic network scheduler and raw event format. Keep this same artifact through DS-9.
- RFC 9114 - HTTP/3IETF · reference
Read Sections 3 (connection setup), 6 (stream mapping) and 7 (framing) for how HTTP semantics map onto QUIC streams.
- W3C Trace ContextW3C · reference
Read Section 3.2 (traceparent fields), Section 3.3 (tracestate) and Section 4 (processing model) for trace correlation without synchronized clocks.