Computer Networks
What Happens When You Type google.com
This is the most popular networking interview question at FAANG. A single question covers DNS, TCP, TLS, HTTP, CDN and lets the interviewer assess depth of understanding at any level.
- **Google SRE**: understanding the flow is critical for diagnosing latency issues and optimizing TTFB (Time To First Byte)
- **Frontend Performance**: knowing where time is spent helps apply the right optimizations (preconnect, dns-prefetch)
- **System Design**: this flow is the foundation for designing any web service with latency requirements
Предварительные знания
DNS Lookup
The first step is **resolving the domain name to an IP address**. The browser doesn't know where to send the request until it receives the IP of Google's server.
**DNS lookup hierarchy**: Browser cache → OS cache → Router cache → ISP DNS → Recursive resolution (Root → TLD → Authoritative)
In practice, most requests hit the browser or ISP cache. The TTL of the record determines how long it lives in the cache - Google uses a short TTL (~300 sec) for flexibility in load distribution.
Why does Google use a short DNS TTL (~5 minutes)?
TCP Handshake
Once the IP address is obtained, the browser establishes a **TCP connection** to port 443 (HTTPS). TCP requires a preliminary handshake - this adds one RTT of latency.
**RTT** (Round Trip Time) - the round-trip time. Moscow → California ≈ 150-200ms. With high RTT, each handshake noticeably slows down page load.
The TCP Handshake also negotiates **Window Size** (how much data to send without acknowledgment) and **MSS** (Maximum Segment Size). This affects connection throughput.
How many RTTs are required to establish a TCP connection?
TLS Handshake
After the TCP connection the browser initiates a **TLS handshake** for encryption. This adds 1-2 more RTTs, but TLS 1.3 and techniques like 0-RTT can reduce the latency.
**SNI** (Server Name Indication) - the client specifies the domain in ClientHello. This allows a single IP to serve many HTTPS sites, but SNI is sent in plaintext (ECH solves this).
The browser verifies the certificate: validity period, CA signature, chain to root CA. On error - shows a warning. Google uses its own CA through Chrome for certificate pinning.
What is transmitted in plaintext even with HTTPS?
HTTP Request & Response
Finally the browser sends the **HTTP request**. Google uses HTTP/2 or HTTP/3, which allows multiplexing requests and compressing headers.
The **alt-svc** header suggests the browser switch to HTTP/3 (QUIC) for subsequent requests. QUIC combines TCP+TLS into a single protocol running over UDP.
Google uses aggressive compression (gzip/brotli), HTTP/2 Server Push, preload hints. The response includes HTML referencing CSS, JS, images - each resource is a separate request (but in HTTP/2 all go over a single connection).
Which HTTP/2 feature is critical for a page with many resources?
Full Flow Timeline
Let's put together the full picture from pressing Enter to the page being displayed. Understanding each step is critical for performance optimization and answering system design interview questions.
**In an interview** break the answer into layers: Application (HTTP), Transport (TCP/QUIC), Security (TLS), Network (IP routing), Link (Ethernet/WiFi). Show how each layer adds to latency.
Google's optimizations: CDN (server close to the user), TCP Fast Open, TLS 1.3 0-RTT, HTTP/3 (QUIC with no handshake on reconnect), preconnect hints in HTML, Service Workers for caching.
HTTPS adds significant overhead and slows down websites
TLS 1.3 adds only 1 RTT, and HTTP/3 (QUIC) combines transport and security into a single handshake. Caching and HTTP/2 advantages often compensate for the overhead
Modern protocols are optimized for minimal latency. 0-RTT resumption, QUIC, certificate caching make HTTPS nearly free. Non-HTTPS sites are actually slower due to the absence of HTTP/2.
What most impacts latency on a first visit to a site from another continent?
Key Takeaways
- **DNS → TCP → TLS → HTTP** - the basic sequence for any HTTPS request
- **RTT dominates** - at long distances handshakes matter more than data size
- **CDN is critical** - bringing the server closer to the user reduces RTT several times over
- **HTTP/3 (QUIC)** - next generation, combines TCP+TLS and runs over UDP
Related Topics
This question ties together many networking concepts:
- DNS Resolution — The first step - converting a domain to an IP
- TLS and HTTPS — Encrypting the connection after the TCP handshake
- HTTP/2 and HTTP/3 — Multiplexing and protocol optimizations
Вопросы для размышления
- How would you optimize page load for users from Australia with servers in the US?
- Why does Google operate its own DNS servers (8.8.8.8) and CDN?
- How will the flow change when using HTTP/3 instead of HTTP/2?