Build a gRPC-style RPC framework

About Build a gRPC-style RPC framework

Every microservice talks over RPC, and the framework you ship determines half the system's failure modes. Build an RPC framework with codec, streams, deadlines, cancellation, retries, interceptors, and load-aware client-side balancing — and feel why gRPC ate the polyglot RPC market and why Thrift and JSON-over-HTTP linger.

Difficulty
advanced
Time
about 85 minutes
Stages
9
Topic
Caching, Proxies & the Edge

How this problem is worked

Nine stages, from what the thing is for to how it compares with the real implementations. Each asks one question, and the simulator runs the architecture you draw against the requirements you wrote.

  1. 01Purpose & invariantsWhat is this for, and what must always be true of it?
  2. 02Workload characterizationWho writes, who reads, and in what shapes?
  3. 03Data model & on-disk formatWhat does the data look like at rest?
  4. 04Core algorithmsHow do the write path and the read path actually work?
  5. 05Distribution & replicationHow does this scale out and survive losing a machine?
  6. 06Consistency & correctnessUnder concurrency and failure, what is guaranteed?
  7. 07Failure modes & recoveryWhat actually happens when each part fails?
  8. 08Operational characteristicsCan a human run this at three in the morning?
  9. 09Trade-offs & comparisonWhere does this sit against the alternatives?

Primary sources for this problem

  • gRPC documentation — Core concepts (the four call types, metadata, channels): grpc.io/docs/what-is-grpc/core-concepts
  • gRPC blog — Deadlines ('always set a deadline'; the resource-exhaustion failure mode): grpc.io/blog/deadlines
  • gRPC guides — Retry policy (maxAttempts, retryable codes, backoff, throttling): grpc.io/docs/guides/retry
  • gRPC blog — Load balancing in gRPC (proxy vs client-side vs look-aside): grpc.io/blog/grpc-load-balancing
  • Kubernetes blog — gRPC load balancing on Kubernetes without tears (the L4 connection-pinning gotcha): kubernetes.io/blog/2018/11/07
  • Birrell & Nelson — Implementing Remote Procedure Calls (TOCS 1984): the origin — stubs, marshalling, binding
  • Waldo, Wyant, Wollrath, Kendall — A Note on Distributed Computing (Sun TR-94-29, 1994): why RPC can't be transparent
  • Protocol Buffers — Encoding (varint, tag = field<<3|wire_type, skipping unknown fields): protobuf.dev/programming-guides/encoding
  • Protocol Buffers — Proto3 language guide (field numbers, reserved, schema-evolution rules): protobuf.dev/programming-guides/proto3
  • Apache Thrift — Architecture / whitepaper (Slee, Agarwal, Kwiatkowski, Facebook 2007): the pluggable transport/protocol contrast
  • RFC 9113 — HTTP/2 (frames, streams, flow control, WINDOW_UPDATE, RST_STREAM): httpwg.org/specs/rfc9113
  • RFC 9000 — QUIC & RFC 9114 — HTTP/3 (per-stream loss recovery; the TCP head-of-line fix)
  • Marc Brooker / AWS Builders' Library — Timeouts, retries, and backoff with jitter (retry storms, metastable failure)
  • Robin Marx — Head-of-line blocking in QUIC and HTTP/3 (app-layer vs transport-layer HOL): github.com/rmarx/holblocking-blogpost
  • Cindy Sridharan — Distributed Tracing in Practice (context propagation across hops)

Browse the full problem catalog, or see what the simulator does and does not model.