System Design Academy

Saving…

Lesson 10 of 10 in Module 10 of 54 lessons complete

Choosing a Protocol

Module 1, lesson 10Concept10 min

Definition

Protocol

In plain English
A protocol is an agreed set of rules for how two programs exchange messages.
Think of it like
It is like the rules of a card game that everyone at the table agrees to.

Trade-off

In plain English
A trade-off is a choice where gaining one benefit means giving up another.
Think of it like
It is like paying more for a faster train.

Why it exists

A daily update rarely needs a connection that stays open. For 50,000 internal calls per second, test a compact format. Choose tools that solve the actual communication problem.

Choose for each connection. A single product can use one protocol for public requests and another for frequent internal calls.

How it works

  1. Identify the caller

    Check whether it is a browser, partner, device or internal service.

  2. Trace direction

    Decide whether updates arrive without a new request and whether replies flow back frequently.

  3. Set a delay budget

    Decide how much update delay users accept before choosing connections that stay open.

Without push, use REST for browsers or partners, or consider gRPC for heavy internal traffic. With updates, consider WebSocket for frequent two-way messages, SSE for frequent one-way messages, and polling for rare changes.

Direction, caller and frequency provide a starting point for choosing a protocol.

Without push, use REST for browsers or partners, or consider gRPC for heavy internal traffic. With updates, consider WebSocket for frequent two-way messages, SSE for frequent one-way messages, and polling for rare changes.

OptionDirectionFormatBrowser supportScaling workTypical use
RESTRequest and responseOften JSONNative HTTPLess work when requests stand alonePublic and partner APIs
gRPCUnary or streamingUsually Protocol BuffersExtra browser toolsVaries with streamingInternal typed calls
SSEServer to clientUTF-8 event textNative EventSourceKeep streams openLive scores and queues
WebSocketTwo-wayText or binaryNative WebSocketConnections and routingInteractive live screens

Examples

Mix protocols for esports fans

An esports scoreboard serves fans and receives statistics from game servers.

Fans receive scores over SSE and fetch match history through REST. Game servers report statistics to the backend over gRPC. Each path has a different caller and message pattern.

The fan browser requests history from the backend over REST, and the backend sends scores over SSE. Game servers send statistics to the backend over gRPC.

The scoreboard selects a protocol for each connection.

The fan browser requests history from the backend over REST, and the backend sends scores over SSE. Game servers send statistics to the backend over gRPC.

The insight

Pick per connection, not per system.

Trade-offs

Pros

  • Match each path to its needs.
  • Keep contracts appropriate to callers.

Cons

  • Maintain more tooling.
  • Monitor several connection patterns.

Use when

  • Communication needs differ by path.
  • The team can operate added protocols.

Avoid when

  • A small team is validating a product.
  • REST meets measured requirements.

Quick check

A live auction page must show new bids instantly and let users bid from the same page many times a minute. Best fit?
A two-person startup builds a booking app MVP. Sensible default?

Takeaways

  • Choose per connection.
  • Ask: who speaks first, how often, and who is calling.
  • Start with REST; add another protocol for a measured need.

Try the quick check above whenever you feel ready.

Previous: Real-Time: Polling, Long Polling, SSE & WebSockets