Skip to content

Try “polymorphism”, “TCP handshake” or “git rebase”.

    Computer Basics / Networking 3: DNS, HTTP and HTTPS

    What Happens When You Type a URL and Press Enter

    This is the capstone of all five Foundations files so far. Practise telling it out loud in about 3 minutes. Each

    Chapter 13 of 135 min readOften asked in interviews

    This is the capstone of all five Foundations files so far. Practise telling it out loud in about 3 minutes. Each step names the file and chapter it came from.

    You type https://studybuddy.app/notes/priya and press Enter.

       1  URL parsed ─────────────────────────────── scheme https → port 443, host, path     [05 Ch 1]
       2  DNS: studybuddy.app → 13.235.10.20 ─────── browser/OS cache, else resolver walk     [05 Ch 2]
       3  route: not my subnet → default gateway ─── ARP for the gateway's MAC                [03 Ch 5,7,8]
       4  NAT at the home router ──────────────────── private IP:port → public IP:port        [04 Ch 10]
       5  TCP handshake SYN / SYN-ACK / ACK ────────── 1 RTT                                   [04 Ch 5]
       6  TLS 1.3 handshake ────────────────────────── cert check, shared key; 1 RTT           [05 Ch 10,11]
       7  HTTP request  GET /notes/priya  Cookie: … ─ encrypted                                [05 Ch 3,6,7]
       8  CDN / load balancer / reverse proxy ──────── TLS ends, forwards to an app server    [05 Ch 12]
       9  app server: socket accept, handler runs ─── process, threads/event loop, DB query   [02 Ch 3,7,11; 04 Ch 2]
      10  HTTP response 200 + HTML/JSON ───────────── Content-Type, Cache-Control             [05 Ch 5,6,8]
      11  browser renders the page ───────────────── fetches CSS/JS/images (reusing the connection) [04_Frontend/01]

    In words:

    1. Parse the URL. The browser sees scheme https (so port 443), host studybuddy.app, path /notes/priya.

    2. Find the IP address with DNS. The browser checks its cache, then the operating system's. If there's no answer, it asks the recursive resolver it got from DHCP, which asks a root server, then the .app TLD servers, then StudyBuddy's authoritative servers, and gets 13.235.10.20 with a TTL. Every layer caches it.

    3. Get the packets moving. The kernel checks the routing table: 13.235.10.20 isn't in the local subnet, so packets go to the default gateway. ARP finds the gateway's MAC address; the frame goes over Wi-Fi.

    4. Leave the home. The home router NATs the private source address and port to the home's public IP and a new port, then forwards the packet; routers across the internet pass it on hop by hop using longest prefix match, while the TTL counts down.

    5. Open a TCP connection — SYN, SYN-ACK, ACK — one round trip.

    6. Secure it with TLS 1.3. The browser sends ClientHello with SNI; the server sends its certificate; the browser verifies the chain up to a trusted root CA and checks the name and expiry; both sides derive a shared symmetric key. One more round trip.

    7. Send the HTTP request, encrypted: GET /notes/priya, with Host, Accept, and the session Cookie.

    8. Pass through the edge. A CDN may answer straight from cache; otherwise the load balancer terminates TLS, adds X-Forwarded-For, and forwards to one of several app servers.

    9. The app handles it. The server process (with its threads or event loop) accepts the connection, its code looks up the session from the cookie, queries the database — over a pooled connection — and builds a response.

    10. Response comes back: 200 OK, Content-Type: text/html, caching headers, the body — sent back the same way, and NAT'd back to your laptop using the router's table.

    11. Render. The browser parses the HTML, discovers CSS, JavaScript and images, fetches them over the same connection (HTTP/2 multiplexing), and draws pixels (How Computers Work Ch 9, and in depth in How the Browser Works (coming soon)).

    For a user in Bangalore and a server in Mumbai (RTT ~20 ms) the network part of a fresh visit is roughly DNS (0–50 ms) + TCP (20 ms) + TLS (20 ms) + request (20 ms + server time). That's why a well-built site feels instant — and why the same site served only from the USA (RTT ~220 ms) takes most of a second before the first byte arrives.