SproutStackSproutStack home

DNS, HTTP, TCP in 10 Minutes

5 min readBeginner-friendlyFree to read

Read a little, play a little. No scary maths, and no rush.

Share:

The journey of a URL

You type sproutstack.dev and press Enter. In the ~500 milliseconds before the page appears, roughly this happens:

  1. DNS — the browser asks a phonebook: "what IP is sproutstack.dev?" Answer: something like 216.198.79.1. This lookup is cached at every layer, so it usually costs nothing.
  2. TCP handshake — your machine and the server agree to talk reliably (SYN → SYN-ACK → ACK). TCP promises every byte arrives, in order, or your money back.
  3. TLS handshake — they negotiate encryption. This is what turns HTTP into HTTPS: same protocol, now with privacy and identity (that padlock means "this server proved it owns the domain").
  4. HTTP request — GET / goes out; HTML, images, and data stream back.
  5. The app's turn — a load balancer picks a server, the app checks cache and database, and the response travels home.
1. lookup2–4. TCP, TLS, GET /5. routereadBrowseryou press EnterDNS resolvername → IP addressLoad balancerpicks a serverApp serverCache + database
Step 1 finds the address. Steps 2 to 4 open a reliable, encrypted connection and send the request. Step 5 is your app's turn.

Inside a request and a response

An HTTP request has four parts: a method (GET to read, POST to create, PUT or PATCH to update, DELETE), a path (/users/42), headers carrying metadata (Host, Authorization, Content-Type, Cache-Control), and an optional body, such as JSON for a POST.

The response carries a status code, its own headers, and a body. The first digit of the status code tells you the category:

  • 2xx: success, such as 200 OK or 201 Created.
  • 3xx: go elsewhere, such as 301 Moved Permanently.
  • 4xx: the client made a mistake, such as 404 Not Found or 401 Unauthorized.
  • 5xx: the server failed, such as 500 or 503.

DNS records you will meet

  • A maps a name to an IPv4 address, and AAAA to an IPv6 address.
  • CNAME makes one name an alias for another, common when pointing a domain at a hosting provider.
  • MX says where email for the domain should go.
  • TXT holds text, often used to prove domain ownership to services such as search engine consoles.

Every record has a TTL (time to live) saying how long others may cache it. This is why a DNS change "takes time to propagate": resolvers around the world keep serving the old answer until their cached copy expires.

TCP vs UDP: certainty vs speed

TCP retransmits lost packets and keeps order — perfect for web pages, where one missing byte corrupts everything. UDP fires packets and hopes: faster, no guarantees. Live video calls and games choose UDP because a frozen frame from 2 seconds ago is worse than a slightly glitchy live one.

The two free speedups

Keep-alive reuses one TCP connection for many requests instead of handshaking per image. A CDN serves static files from a city near the user instead of across an ocean. Together they erase most of the latency in that 500 milliseconds.

HTTP versions in one breath

HTTP/1.1 sends requests one after another on each connection. HTTP/2 carries many requests at once over a single connection. HTTP/3 runs on QUIC, which is built on UDP, so one lost packet no longer stalls every other request sharing the connection, a problem known as head-of-line blocking.

Remember this

  • URL → DNS → TCP → TLS → HTTP → app → database. Say it in order, earn the nod.
  • Reliability costs round trips; speed costs certainty. Name which one each protocol chose.

Check your understanding

5 questions · first-try answers earn the most XP

1. What does DNS do in the journey of loading a page?
2. Why does the chapter say reliability costs round trips in TCP?
3. Why do live video calls often use UDP rather than TCP?
4. What do keep-alive connections and a CDN each remove from page load time?
5. What does the TLS handshake add beyond encryption?

My notes

Saved in this browser. Highlight a line above and save it, or write it in your own words.

Nothing saved yet. Your highlights will live here.

References

Finished reading?

Ticking it here also ticks the chapter in the sidebar, the section count and your streak — it is all one number.

Practice this in an incident

Try a design drill

Related chapters

Spotted a mistake or want a topic covered? Report an issue

📬 An occasional email when new lessons land

New lessons and showdowns, no more than a few times a month. No spam, unsubscribe anytime. We store your email only to send the newsletter.