Part I β The Pipes
2 Communication
GoalChoose the right real-time transport for a given update frequency and direction.
- 2.1 Communication Overview Two questions decide everything: who starts the message, and how often does it arrive?
- 2.2 Short Polling Ask the server every N seconds. Simple, stateless, and mostly wasted requests.
- 2.3 Long Polling The client asks, and the server holds the request open until it actually has news.
- 2.4 Web Sockets One HTTP request upgrades into a persistent two-way pipe that stays open for the session.
- 2.5 Server Side Events A one-way stream over ordinary HTTP that reconnects and resumes by itself.
- 2.6 WebHooks Server-to-server push: you register a URL, and the other system calls you when something happens.
- 2.7 Picking a Transport Answer three questions in order β direction, frequency, tolerance for staleness β then defend the cost.
Capstone
Pick and justify a transport for each: stock ticker, chat, CI build log, order status, payment confirmation.