# Client-Server Model and How the Internet Works

> Follow a request from a browser or mobile app through the network to a server and back, and learn the layers that make it possible. Free notes, key concepts,...

Canonical: https://www.internhack.in/roadmaps/tracks/system-design/client-server-internet
Last updated: 2026-11-28

Follow a request from a browser or mobile app through the network to a server and back, and learn the layers that make it possible.

Beginner · about 3 hours · difficulty 1/5

Learn first: [What System Design Is (HLD vs LLD)](https://www.internhack.in/roadmaps/tracks/system-design/what-is-system-design)

Almost every system you will design is a **client-server** system. A client (browser, Android app, another service) sends a request; a server processes it and sends a response. Knowing what happens in between helps you reason about latency and failure.

### The path of a request

1. The client resolves a domain name to an IP address using **DNS**.
2. It opens a **TCP** connection (a three-way handshake) and, for HTTPS, performs a **TLS** handshake.
3. It sends an **HTTP** request over that connection.
4. Packets hop across routers and ISPs using **IP**, possibly through a CDN or load balancer.
5. The server responds; the client renders or uses the data.

Every step adds round trips. A user in Patna talking to a server in Mumbai pays roughly 30 to 50 ms per round trip, and a fresh HTTPS connection can need three or four round trips before the first byte.

### Layers worth knowing

- **IP**: addressing and routing, best effort delivery.
- **TCP**: reliable, ordered byte streams with congestion control. Used by HTTP/1.1 and HTTP/2.
- **UDP**: no handshake, no guarantees. Used by DNS, video calls, games and QUIC (HTTP/3).
- **TLS**: encryption and server identity on top of TCP.

### Stateless vs stateful servers

A **stateless** server keeps no per-user memory between requests, so any instance can handle any request and you can scale by adding instances. Session data then lives in a shared store such as Redis or a database. Stateful servers (WebSocket chat servers, game servers) are harder to scale and need sticky routing.

### Pitfalls

- Ignoring the cost of new connections; connection reuse and keep-alive matter at scale.
- Assuming the network is reliable. Packets drop, connections reset and timeouts happen.

You are ready to move on when you can explain every step between typing a URL and seeing the page, and say which steps add latency.

## Key concepts

- **Client-server model**
- **IP, TCP and UDP**
- **TLS handshake**
- **Round trips and network latency**
- **Stateless vs stateful servers**
- **OSI vs TCP/IP model**

## Mini project

Use curl with timing output (curl -w) against five websites hosted in different regions and record DNS, connect, TLS and first-byte times. Write a short note explaining which phase dominates and why.

## Check yourself

Why does making a web server stateless make horizontal scaling easier, and where does the session data go instead?

## Free resources

- [Cloudflare Learning Center](https://www.cloudflare.com/learning/) (Cloudflare)
- [High Performance Browser Networking](https://hpbn.co/) (Ilya Grigorik)
- [An overview of HTTP](https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview) (MDN)

Previous: [What System Design Is (HLD vs LLD)](https://www.internhack.in/roadmaps/tracks/system-design/what-is-system-design) · Next: [HTTP, Connections and Real-Time Protocols](https://www.internhack.in/roadmaps/tracks/system-design/http-for-system-design)

## 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)
