1. What happens when you type a URL into your browser and press Enter?
Mid-leveldnstcptls
What the interviewer is really testing
Whether you hold a correct end-to-end model of a request, from naming through transport and encryption to routing and the application, and whether you can choose where to go deep instead of reciting every layer at the same shallow level.
Show the model answer, follow-ups and checklist
Model answer
I will go through it in order and then go deeper wherever is most useful to you.
- URL and caches. The browser parses the URL and decides on HTTPS. It checks whether it already has a fresh cached response, or an open connection to that host it can reuse.
- DNS. With no cached address, the operating system’s stub resolver asks a recursive resolver. On a cold cache that resolver asks a root server, the TLD server and the domain’s authoritative server, then caches the answer for its TTL. The answer is often already a routing decision: a nearby CDN edge chosen by GeoDNS, or an anycast address.
- Connection. A TCP three-way handshake costs one round trip. The TLS 1.3 handshake costs one more: the server sends its certificate chain, the browser validates it against its trust store, and both derive session keys. They agree on HTTP/2 during that handshake. If the browser knows the site supports HTTP/3, it uses QUIC and gets transport and encryption set up in a single round trip.
- Request. The browser sends
GET /with headers and cookies. It arrives at a CDN edge or a load balancer, which terminates TLS. Cached content is answered there. Anything else goes to a healthy application server, possibly through an API gateway that checks authentication and rate limits. - Application. The server runs the handler, reads from a cache or database, and returns a status, headers that say how the response may be cached, and a body.
- Render. The browser parses the HTML, discovers stylesheets, scripts and images, and fetches them, mostly as parallel streams on the same connection. Then it lays out the page and runs scripts.
On a cold start that is roughly four round trips before the first byte: DNS, TCP, TLS and the request. That is why connection reuse, CDNs and HTTP/3 matter so much to users far from the servers.
Likely follow-ups
- Which of those steps are skipped on a second visit a minute later?
- Most of them. The DNS answer is cached in the browser, the operating system and the resolver. The connection is probably still open, so there is no TCP or TLS handshake, and if it closed, TLS session resumption shortens the new one. Static assets come from the browser cache with no request at all while they are fresh, or with a cheap conditional request that returns 304.
- The user typed only the domain. How does the browser know to use HTTPS?
- If the site has sent a Strict-Transport-Security header before, or is on the browser preload list, the browser upgrades to HTTPS before sending anything. Modern browsers also increasingly try HTTPS first for typed addresses. Otherwise the first request goes over plain HTTP and the server redirects, which is the window HSTS exists to close.
- Where does the server learn the client IP address, and where can that go wrong?
- The CDN or load balancer sees the real source address. An L7 proxy opens its own connection to the backend, so the backend sees the proxy address and must read the original from a header such as X-Forwarded-For, or from the PROXY protocol at L4. That header is only trustworthy when it was set by your own proxy, because any client can send one.
- The page loads in 200 ms near the data centre and 3 seconds from another continent. Where do you look first?
- At round trips multiplied by distance, since server time is the same for both users. I would count how many round trips happen before the first byte and during asset loading, then check whether connections terminate near the user at a CDN, whether assets are cached at the edge, and whether connections are being reused over HTTP/2 or HTTP/3.
Common mistakes
- Spending the whole answer on ARP, Ethernet frames and routing tables and never reaching the load balancer or the application.
- Listing layers with no sense of cost, never mentioning round trips or caching.
- Leaving out TLS, or describing it before the TCP handshake.
- Saying DNS returns the IP of "the server", when it is normally a CDN edge or a load balancer.
- Forgetting that the browser then fetches dozens of sub-resources, mostly over the same connection.
A strong answer includes
- DNS resolution through a recursive resolver, with caching and TTLs
- TCP handshake, then TLS handshake with certificate validation, or QUIC doing both in one round trip
- HTTP version negotiation and connection reuse
- A CDN or load balancer in front of the servers, and where TLS terminates
- The application and data tier in a sentence or two
- The browser parsing HTML and fetching sub-resources, using its cache
- A count of round trips, or another clear statement of where the latency comes from
- An offer to go deeper on one part instead of equal weight everywhere
Revise: DNS