Protocols, RPC and Ambiguous Outcomes
Every later guarantee crosses a protocol boundary. Framing, compatibility, deadlines and retry semantics must therefore be explicit before replication or consensus can be trusted.
Section 1 of 9 · 13 units · about 51 hours
By the end you can Pass a mixed-version fault matrix covering partial I/O, oversized or corrupt frames, timeout ambiguity, duplicate mutation, cancellation, overload, restart and rollback, then state exactly which effects may repeat.
Units
- Request, response and streaming state machines, and textual versus binary encoding4h
- Schema fields, defaults, unknown-field preservation and wire compatibility4h
- Length-prefixed and delimited framing, partial reads and writes and coalesced messages4h
- Message size, allocation and decompression limits, and checksum boundaries3h
- Request IDs, client incarnations and idempotency keys4h
- Ambiguous outcomes after timeout and monotonic deadline propagation3h
- Bounded retries, exponential backoff with jitter and duplicate-suppression state4h
- Structured errors, cancellation propagation and streaming flow control4h
- Authentication, authorization, service discovery and gRPC interceptors4h
- Connection pools, load balancing, health and HTTP/3 transport behavior4h
- Bounded queues, end-to-end backpressure, overload rejection and retry amplification4h
- Trace correlation without synchronized clocks and a deterministic faulty network4h
- Versioned framed RPC, a mixed-version test matrix and the rollout contract5h
Build it
Mini project · about 14 to 20 hours
Versioned RPC with replayable faults and bounded work
Create loglab, the reduced data system carried through this track, in your chosen implementation language. Build a versioned framed RPC between processes on your machine, with deterministic correctness gates before timing runs and explicit boundaries for retries, identity and overload.
- 1Create
loglabwithproto/,net/,clock/,member/,storage/,replica/,consensus/,shard/,txn/,stream/,ops/,spec/,history/,faults/,bench/,tests/andreports/. Record unary and streaming state machines inproto/; check legal transitions against gRPC lifecycles and retain transition fixtures. - 2Build versioned length-prefixed framing and a delimited comparison parser. Keep split-header, split-body, coalesced and split-delimiter fixtures, pre-allocation and decompression limits, and checksum corruption tests; compare encodings and preserve a schema-evolution compatibility table checked against independent decoders, including unknown-field round trips.
- 3Implement caller, incarnation, request and intent identities, atomic effect-plus-dedup transitions, parameter-mismatch rejection and bounded retention. Against a sequential intent model, test timeout windows, restart, remaining monotonic budgets, classified retries, jitter and token throttling; retain histories and a derived retry-amplification bound.
- 4Add a token-issuing test client, authenticated channel and pre-dispatch authorization interceptor with a per-method policy table. Compare decisions with independent policy fixtures; inject stale discovery generations and keep denial, identity-propagation and versioned redirect traces proving rejected calls never mutate state.
- 5Bound queues and connection checkout, add health-gated balancing, streaming half-close, flow control, cancellation propagation and drain. Check against a resource-ownership model; retain exhaustion and deadlock regressions plus cleanup traces, and explain the TCP versus QUIC transport boundary without implementing QUIC.
- 6Cross client, server, schema and endpoint versions under deterministic delay, loss, duplication, reordering, partition, corruption, disconnect, restart and cancel schedules. Join traces by causal IDs, not timestamps; retain replay diffs, minimized failures, rollback verdicts and separate MIT 6.5840 Lab 2 and DSLabs Lab 1 results.
- 7After correctness passes, compare shedding policies and affinity under repeated open-loop saturation and recovery runs. Check offered, admitted, rejected, retried and completed counts against raw histories; retain latency distributions, throughput, goodput, queue and pool occupancy, observer overhead, versions and workload descriptions.
What you hand in
- The
loglablayout, versioned protocol, bounded RPC implementation and deterministic network with causal event histories. - Compatibility fixtures, independent state and policy checks, public-suite results, minimized regressions and rollout, rollback and idempotency contracts.
- A measurement report rebuilt from repeated raw runs, with workload, versions, accounting boundaries and retained policy trade-offs.
How to check it
- Self-grade with the rubric below
- MIT 6.5840 Lab 2: Key/Value server and lock tests
Keep reliable, unreliable and lock results separately; extend their ambiguity cases in your own matrix. Do not publish course solutions.
- DSLabs Lab 1: at-least-once and exactly-once RPC
Retain Parts 2 and 3 search-test results; distinguish their sequential-client assumptions from your socket, restart and retention tests.
How it's graded
Wire and evolution
Pass: Own framing and corruption tests match fixed byte fixtures; independent decoders confirm schema crossings and unknown-field behavior. Mixed-version rollback retains meaning and rejects incompatible requests.
Great: A planted field-reuse or lossy-proxy defect fails before repair; the minimized crossing remains a regression through rollback.
Intent and ambiguity
Pass: Own histories match the sequential intent model across timeout windows, restarts, parameter conflicts and expiry. The contract names atomicity and retention limits; public-suite evidence is separate.
Great: A planted non-atomic dedup defect yields a minimized counterexample; delayed retries outside retention explicitly bound the guarantee.
Authority and resources
Pass: Independent policy fixtures and ownership assertions catch unauthorized dispatch, stale generations, leaks, unbounded checkout and stream deadlock. Cancellation and drain release owned resources without claiming effects were undone.
Great: Failures combined with discovery refresh or cancellation expose a naive fix; repaired transition-level regressions preserve rejection and cleanup evidence.
Replay and measurement
Pass: Own replay tests reproduce raw histories exactly; causal joins ignore display timestamps. Repeated measurements follow correctness gates and reconcile counters with histories under named workloads and versions.
Great: A minimized fault and a losing policy regime survive the final report; observer overhead and queue-versus-service decomposition bound each performance claim.
Resources
- DDIA 2e - Chapter 5 Encoding and EvolutionMartin Kleppmann and Chris Riccomini
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.
- gRPC Guides - Deadlines, Cancellation, Status Codes, Retry and Flow ControlgRPC Authors
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
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.
- MIT 6.5840 - RPC and Threads plus Lab 2 Key/Value ServerMIT PDOS
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. - HLD Handbook - Networking, API Design and BackpressureHLD Handbook
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
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.
- Building Distributed Systems - The MessengerBuild Distributed Systems
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)
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 - Making Retries Safe with Idempotent APIsAmazon Web Services
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.
- Beej's Guide to Network ProgrammingBrian Hall
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.
- Replicated Log and Stream Processor - Protocol SliceRoadmap-Final
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.
- Building Distributed Systems - The NetworkerBuild Distributed Systems
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
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.
- RFC 9000 - QUIC Version 1IETF
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
Read Sections 3 (connection setup), 6 (stream mapping) and 7 (framing) for how HTTP semantics map onto QUIC streams.
- W3C Trace ContextW3C
Read Section 3.2 (traceparent fields), Section 3.3 (tracestate) and Section 4 (processing model) for trace correlation without synchronized clocks.