← All system designs

Communication Patterns

HTTP and its evolution, RPCs, WebSockets, and the textual + binary data formats every API designer must read fluently.

7 items 3 Foundational 4 Intermediate

Once you've chosen to design an API, the next decision is how to move the bytes. HTTP is the default — but HTTP 1.1, HTTP/2, and HTTP/3 differ in ways that affect API design (multiplexing, head-of-line blocking, the QUIC handshake). Below HTTP sits RPC (function-call-shaped) and above it sit WebSockets (long-lived bidirectional). The choice shapes the contract.

And then there's the payload. JSON won, but XML still ships in enterprise APIs and YAML still configures everything. Protobuf, MessagePack, and Avro buy you wire efficiency at the cost of debuggability. Picking the format for an API is as load-bearing as picking the verb.

Key concepts

  • HTTP is the default, but HTTP/2 and HTTP/3 change the multiplexing story significantly
  • RPC is request/response framed as a function call — its leaks are well-documented
  • WebSockets is the long-lived bidirectional escape from HTTP's request/response shape
  • JSON is the lingua franca; XML still lives in older enterprise APIs
  • Binary formats (Protobuf, Avro, MessagePack) trade debuggability for wire size and parsing speed

Reference template

// Picking a communication pattern
1. Is the interaction request/response or push?  (HTTP vs WebSockets vs SSE)
2. Is the client polyglot?                       (REST/HTTP wins; gRPC requires codegen)
3. Is payload size dominant?                     (binary formats; otherwise JSON)
4. Is schema evolution central?                  (Protobuf/Avro give you that for free)
5. Is the call truly function-call-shaped?       (then RPC); else REST

Adapt to your problem; the structure is the load-bearing part.

Common pitfalls

  • Choosing HTTP/2 in production then hitting a load balancer that downgrades to 1.1
  • Using WebSockets where SSE or long-polling would have been simpler
  • Picking Protobuf when nobody on the team can debug binary payloads at 3am
  • Letting YAML's whitespace bite a deploy because someone copy-pasted from a doc

Related topics

Items (7)

Search ESC

Keyboard shortcuts

Shortcuts are disabled while typing in inputs.