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.

Beginner · about 3 hours · difficulty 1/5

Learn first: What System Design Is (HLD vs LLD)

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