Unit 13 of 13 · about 5 hours · implement, measure
Versioned framed RPC, a mixed-version test matrix and the rollout contract
This is the DS-1 exit gate in code. Everything before it was a part; this unit proves the parts survive each other and a rollout.
You'll be able to
- Implement a versioned framed RPC with caps, checks, identities, deadlines and structured errors.
- Pass a mixed-version matrix covering partial I/O, corrupt frames, ambiguity, duplicates, cancel, overload, restart and rollback.
- State the rollout and rollback contract: what may repeat, what never repeats, and how callers detect ambiguity.
Covers
Read
In this order, only the parts listed
0 of 3 done
- DDIA 2e Chapter 5 rollout and evolutionDDIA 2e - Chapter 5 Encoding and Evolution
Chapter 5, Dataflow Through Services (pp. 180-186) for rolling upgrades with mixed versions, and Avro and Protobuf sections (pp. 169-177) for the compatibility rules the matrix checks
- MIT 6.5840 Lab 2 as the mixed-version harness modelMIT 6.5840 - RPC and Threads plus Lab 2 Key/Value Server
Versioned
PutwithErrVersion,ErrNoKeyandErrMaybeplus lock tests; Spring 2026 suiteTestReliablePut,TestUnreliableNet,TestOneClientUnreliable,TestManyClientsUnreliable - Beej partial-send loop for the transport edgeBeej's Guide to Network Programming
Section 7.4 Handling Partial send:
sendallloop; Section 5.7 for short sends and close semantics applied at the frame boundary
Focus on
- Version every layer once: envelope version, schema version and endpoint generation. The matrix crosses old and new on each axis, not just one happy-path pair.
- Rollout order is part of the contract: expand (add, ignore), migrate (dual-write, backfill), contract (remove) with reserved numbers held through rollback.
- The fault list is the section checkpoint: partial I/O, oversized and corrupt frames, timeout ambiguity, duplicate mutation, cancellation, overload, restart and rollback.
- Measure on your machine as labeled examples: latency distributions and throughput over payload and concurrency regimes, plus retry, duplicate and rejection counts. Numbers from papers or vendor docs stay cited with their setups, never as targets.
Common mistakes · 3
- Testing only new-to-new. Production is mixed for the whole rollout window, so old-to-new and new-to-old with rollback are the cases that corrupt data.
- Removing a field and freeing its number at release time. Rollback resurrects the old binary, which then misreads the reused number; reserve through the rollback horizon.
- Reporting a latency number without its setup. Name versions, workload, concurrency, durability settings, run count and spread, or the number is not comparable.
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.What rows does the minimum mixed-version matrix need?Answer
Old client with old server, old with new, new with old, and new with new, each under partial I/O, corrupt frames, timeout, duplicate, cancel, overload, restart and rollback faults.
2.Rollback happens one hour after a field removal. What breaks if the number was reused immediately?Answer
The rolled-back old binary reads new bytes under the old meaning, or new bytes under the reused meaning corrupt old state. Reservations must outlive the rollback window.
3.A test times out but the effect applied. How does the matrix classify it?Answer
Ambiguous, not failed. The caller reconciles by idempotency key and the history records maybe, matching the
ErrMaybediscipline from Lab 2.4.What must the rollout contract state about repetition?Answer
Exactly which requests or effects may repeat, inside which identity and retention boundary, and how callers detect or tolerate the ambiguous cases.
Practice
- MIT 6.5840 Lab 2: full Key/Value plus lock suite
Pass
TestReliablePut,TestPutConcurrentReliable,TestUnreliableNetand all lock tests; Spring 2026, Go 1.22 or laterPublic study material; never publish solutions. Then extend with size-limit, cancellation and mixed-version faults in your own matrix.
- DSLabs Lab 1: exactly-once RPC parts 2 and 3
Part 2 at-least-once then Part 3 exactly-once shim via
run-tests.py --lab 1 --part 2andrun-tests.py --lab 1 --part 3; Java 21Search tests print minimal violating traces. Compare its ordering coverage with your seeded socket-level matrix and state what each harness misses.
You're done when
The full matrix passes on your machine with retained seeds and histories, rollback restores the old version without corruption, and the contract names every repeatable effect.
Only when you can do this without notes.
Leads to
Notes
Resources · 3 for this unit, 13 more in the 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.
- 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. - 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.
Also in this 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.
- 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.
- 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. - 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.
- 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.
- 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 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.
- 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.