How the internet works
Every system design rests on the network underneath. What actually happens when you type https://shop.example/products?id=42 and press Enter? Knowing the steps (DNS, TCP, TLS, HTTP) explains where latency comes from, why CDNs help, and what load balancers and caches actually sit in front of.
The journey of a request
1. Parse the URL https | shop.example | /products | ?id=42
2. DNS lookup shop.example → 203.0.113.10
3. TCP connection SYN → SYN-ACK → ACK (1 round trip)
4. TLS handshake agree keys, verify the certificate (1 round trip with TLS 1.3)
5. HTTP request GET /products?id=42 (1 round trip)
6. Server work load balancer → app server → cache/database
7. Response 200 OK + HTML/JSON, then images, CSS, JS (often from a CDN)URLs
DNS: the internet's phone book
Computers connect to IP addresses (203.0.113.10, or IPv6 like 2001:db8::1), not names. The Domain Name System translates names to addresses through a hierarchy:
browser cache → OS cache → resolver (your ISP, 8.8.8.8, 1.1.1.1)
→ root server ("who handles .example?")
→ TLD server ("who handles shop.example?")
→ the domain's authoritative name server ("shop.example is 203.0.113.10, TTL 300")Every answer has a TTL (time to live): how long it may be cached. Caching is what makes DNS fast:
DNS is also a system design tool:
- Load distribution: return several IPs, or different IPs per region (GeoDNS), so users reach a nearby data centre.
- Failover: health-checked DNS stops returning the IPs of a failed region.
- Migrations: lower the TTL a day before moving servers, so the change spreads quickly.
TCP and UDP
| TCP | UDP | |
|---|---|---|
| Connection | Handshake first (SYN, SYN-ACK, ACK) | None |
| Delivery | Reliable, ordered, retransmits lost packets | Best effort; packets may be lost or reordered |
| Speed | Extra round trips and overhead | Minimal |
| Used for | Web pages, APIs, databases, email | Video calls, games, DNS queries, and QUIC (HTTP/3) |
Every new TCP connection costs a round trip before any data flows. That's why clients reuse connections (HTTP keep-alive, connection pools to databases).
TLS and HTTPS
TLS encrypts the connection and proves the server's identity with a certificate signed by a trusted authority. TLS 1.3 needs one round trip (zero for resumed sessions). In production systems, TLS is usually terminated at the load balancer or CDN, and traffic inside the private network may be re-encrypted (mTLS) for defence in depth.
HTTP versions
| Version | Key change |
|---|---|
| HTTP/1.1 | One request at a time per connection; browsers open ~6 connections per host |
| HTTP/2 | Many requests multiplexed over one connection; header compression |
| HTTP/3 | Runs over QUIC (on UDP): faster handshakes, and one lost packet no longer stalls every stream |
Adding up the latency
Round trips dominate, and they depend on physical distance (light in fibre travels about 200 km per millisecond):
This is why global products put servers and CDNs (content delivery networks: caches in hundreds of cities) close to users, and why a page that makes ten sequential API calls feels slow.
What's on the server side
When the request reaches the system, it typically passes through:
- CDN / edge: serves cached static files and sometimes whole pages; blocks attacks.
- Load balancer: spreads requests across app servers, terminates TLS.
- API gateway (optional): authentication, rate limiting, routing to services.
- Application servers: run the business logic.
- Caches, databases, queues, object storage: hold and move the data.
The rest of this track opens each of those boxes.
Practice
- Use
dig shop.exampleornslookupon your computer to see a real DNS answer and its TTL. - In the latency model, how much does HTTP keep-alive save on the cross-continent case?
- Explain why a CDN makes a site faster for users far from the origin server.
1.What does DNS do?
2.Why do clients reuse TCP connections?
3.What problem does HTTP/3 solve compared with HTTP/2?