Metadata Card
- Prerequisites: Vol 4 Networking (TCP, HTTP/2), Chapter 1 (Distributed Systems Challenges)
- Estimated Time: 40 minutes
- Core Difficulty: Intermediate
- Reading Mode: High focus
- Completion Milestone: Design a Protobuf schema, use gRPC's four call patterns, understand Thrift vs gRPC design differences
Your Progress
On the battle map, you see communication lines between different outposts — forward stations report to command, reconnaissance units pull data from intelligence. You learned last chapter that these lines can break at any time, but you haven't considered: what do the data packets on these lines look like? How do sender and receiver ensure mutual understanding?
General Lin says: "The sentry and command must not speak different dialects." Your Task
Master RPC (Remote Procedure Call) and serialization. Understand why JSON/REST isn't enough at scale — schema constraint, efficiency, streaming, IDL contracts.
gRPC: HTTP/2 transport, Protobuf serialization. Four call modes: Unary, Server Streaming, Client Streaming, Bidirectional Streaming.
Protobuf: Binary encoding, no field names transmitted, varint encoding for integers. 3-10x smaller than JSON.
Thrift: Facebook's RPC framework. Pluggable layers (transport, protocol, server). Broader language support (30+). No native streaming.
Key design differences: gRPC has HTTP/2 multiplexing, native streaming, deep K8s/Envoy/Istio integration. Thrift has pluggable serialization and transport, broader legacy language support.
Deadline: Always set deadlines on gRPC calls. Default is no timeout — a deadlocked server hangs the client forever.
Common Pitfalls: Treating .proto as an implementation detail, ignoring Deadline, changing field numbers frequently (breaks backward compatibility), assuming gRPC auto-handles retry and load balancing.
Traveler's Notes
RPC disguises remote calls as local calls — this is convenience, but also a dangerous abstraction. Understand what's happening underneath: how Protobuf encodes values on field numbers, how HTTP/2 multiplexes streams, why Deadline can't be omitted.
Next: Consistency & Consensus (Chapter 3).