# HTTP, Connections and Real-Time Protocols

> Learn the HTTP features that shape system design (methods, status codes, caching headers, HTTP/2 and HTTP/3) and the options for real-time push. Free notes,...

Canonical: https://www.internhack.in/roadmaps/tracks/system-design/http-for-system-design
Last updated: 2026-11-28

Learn the HTTP features that shape system design (methods, status codes, caching headers, HTTP/2 and HTTP/3) and the options for real-time push.

Beginner · about 3 hours · difficulty 2/5

Learn first: [Client-Server Model and How the Internet Works](https://www.internhack.in/roadmaps/tracks/system-design/client-server-internet)

HTTP is the language most of your components will speak, so its details show up in every design discussion.

### The parts that matter for design

- **Methods**: GET is safe and should be cacheable; PUT and DELETE are idempotent; POST is neither by default. This drives retries and caching.
- **Status codes**: 2xx success, 3xx redirect (a URL shortener lives on 301 vs 302), 4xx client error (429 means rate limited), 5xx server error (retry candidates).
- **Headers**: Cache-Control, ETag and Last-Modified for caching; Authorization for identity; Idempotency-Key for safe retries.

### Versions

- **HTTP/1.1**: one request at a time per connection, so browsers open several connections.
- **HTTP/2**: many streams multiplexed over one TCP connection, header compression. Head-of-line blocking still exists at the TCP layer.
- **HTTP/3**: runs on QUIC over UDP, avoids TCP head-of-line blocking and handles network switches (Wi-Fi to 4G) better.

### Getting data to clients in real time

- **Short polling**: client asks every few seconds. Simple, wasteful.
- **Long polling**: server holds the request until there is news. Works everywhere.
- **Server-Sent Events (SSE)**: one-way stream from server to client over HTTP. Good for live scores and notifications.
- **WebSockets**: full duplex, persistent connection. Used for chat, multiplayer and trading screens.

Persistent connections change your scaling story: a server may hold lakhs of open sockets, and you need a way to route a message to whichever server holds the recipient's connection.

### Pitfalls

- Using POST for everything and losing caching and safe retries.
- Choosing WebSockets when SSE or polling every 30 seconds would do.

You are ready to move on when you can pick between polling, SSE and WebSockets for a cricket score app, a chat app and an order tracking page, with a reason for each.

## Key concepts

- **Methods, safety and idempotency**
- **Status codes that matter**
- **Caching headers**
- **HTTP/2 and HTTP/3**
- **Long polling**
- **Server-Sent Events**
- **WebSockets**

## Mini project

Build a tiny server that pushes a live counter to the browser three ways (polling, SSE and WebSocket). Measure requests per minute for each with 10 open tabs and write down the trade-offs.

## Check yourself

Why is it safe for a client to retry a timed-out PUT but risky to retry a timed-out POST that creates an order?

## Free resources

- [MDN HTTP documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP) (MDN)
- [The WebSocket API](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) (MDN)
- [RFC 9110: HTTP Semantics](https://datatracker.ietf.org/doc/html/rfc9110) (IETF)

Previous: [Client-Server Model and How the Internet Works](https://www.internhack.in/roadmaps/tracks/system-design/client-server-internet) · Next: [Latency Numbers and Performance Metrics](https://www.internhack.in/roadmaps/tracks/system-design/latency-numbers)

## More in System Design Foundations

- [What System Design Is (HLD vs LLD)](https://www.internhack.in/roadmaps/tracks/system-design/what-is-system-design)
- [Client-Server Model and How the Internet Works](https://www.internhack.in/roadmaps/tracks/system-design/client-server-internet)
- [HTTP, Connections and Real-Time Protocols](https://www.internhack.in/roadmaps/tracks/system-design/http-for-system-design)
- [Latency Numbers and Performance Metrics](https://www.internhack.in/roadmaps/tracks/system-design/latency-numbers)
- [Back-of-the-Envelope Estimation](https://www.internhack.in/roadmaps/tracks/system-design/back-of-envelope-estimation)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [System Design Roadmap](https://www.internhack.in/roadmaps/tracks/system-design)
