HLDFundamentals6 min read

What Happens When You Type a URL in Your Browser?

Follow one HTTPS request from Enter key to painted pixel across DNS, TCP, TLS 1.3, CDN, load balancer, Redis, and PostgreSQL.

Kshitij SinghKshitij SinghUpdated 2026-12-03
Animated system design diagram of what happens when you type a URL — 1. DNS resolution finds the nearest edge IP addressPictorial system design diagram tracing a browser URL request through DNS resolver, CDN edge, Layer-7 load balancer, application servers, Redis cache, and PostgreSQL database.. After parsing the URL, the browser checks its DNS cache and OS resolver. On a miss, a recursive resolver (like 1.1.1.1) queries root, TLD, and authoritative servers. Anycast GeoDNS returns the closest healthy Edge PoP IP.EDGE & RESOLUTIONROUTING & COMPUTECACHE & DATA TIERDNS QueryHTTPS / TLSOrigin FetchHTTP/2 ProxyGET keySQL SELECTBrowser / AppHTTPS ClientDNS ResolverAnycast · UDP 53104.18.2.9CDN Edge PoPTLS + Static CacheL7 Load BalancerReverse ProxyApp Server PoolStateless Go / NodeRedis CacheIn-Memory · ~1msPostgreSQL DBDurable Disk · ~18msA api.shop.com?104.18.2.9
Animated system design diagram of what happens when you type a URL — 1. DNS resolution finds the nearest edge IP address
1 / 6

1. DNS resolution finds the nearest edge IP address

After parsing the URL, the browser checks its DNS cache and OS resolver. On a miss, a recursive resolver (like 1.1.1.1) queries root, TLD, and authoritative servers. Anycast GeoDNS returns the closest healthy Edge PoP IP.

Cached DNS takes under 1ms. A cold recursive lookup burns 20–60ms before TCP even starts.

Elapsed Time
22 ms
+22ms DNS
Round Trips
1 RTT
UDP 53
Origin Load
0%
Untouched
Protocol
DNS / DoH
TTL 300s
Read all 6 diagram steps as text
  1. 1. DNS resolution finds the nearest edge IP address

    After parsing the URL, the browser checks its DNS cache and OS resolver. On a miss, a recursive resolver (like 1.1.1.1) queries root, TLD, and authoritative servers. Anycast GeoDNS returns the closest healthy Edge PoP IP.

  2. 2. TCP three-way handshake and TLS 1.3 terminate at the CDN Edge

    The browser completes a TCP three-way handshake (SYN, SYN-ACK, ACK) and TLS 1.3 negotiation with a CDN Edge PoP 10–15ms away instead of crossing oceans. TLS 1.3 takes 1 RTT (0-RTT on resumed sessions). Static files and cached pages finish right here.

  3. 3. Dynamic API calls route through the L7 Load Balancer to app pods

    Live inventory and user pricing cannot sit in public edge cache. The CDN forwards GET /api/v1/product/sku-42 over a warm HTTP/2 connection pool to your origin L7 Load Balancer (reverse proxy), which sends it to the least-busy healthy app pod.

  4. 4. Cold Redis cache miss falls back to PostgreSQL on SSD

    The app checks Redis for product:sku-42 first (Cache-Aside). Redis returns nil in under 1ms. The app queries PostgreSQL through PgBouncer, runs a B-Tree primary key lookup (~18ms), and writes the result into Redis with a 5-minute TTL.

  5. 5. Warm Redis hits shield PostgreSQL from 95%+ of read load

    Every subsequent shopper requesting sku-42 hits Redis RAM in 0.9ms. PostgreSQL sees zero reads for that key, keeping database CPU flat and cutting backend p99 latency by over 85%.

  6. 6. Brotli response returns and browser rendering paints the page

    The app returns HTML/JSON with Cache-Control and ETag headers through the load balancer and CDN. Brotli shrinks a 48KB payload to ~8KB over HTTP/2. The browser parses HTML into the DOM, applies CSS, and paints pixels in under 45ms network time.

Architecture Flow Summary

Save image
Flow diagram infographic of what happens when you type a URL: Browser to DNS Resolver (22ms), CDN Edge with TCP and TLS 1.3 (26ms), L7 Load Balancer over HTTP/2, App Servers, Redis Cache (1ms hit), and PostgreSQL DB (18ms miss)
End-to-end web request flow from browser URL to Redis cache hit or PostgreSQL read, with typical latency at each hop.

Where Latency Actually Goes

Most engineers jump straight to SQL tuning when a site feels slow. That misses the bigger picture. Cutting a query from 12ms to 6ms barely shows up if a user on 4G spends 280ms on cold DNS, TCP three-way handshake, and TLS handshakes to a distant region.

Break every request into three buckets: WAN handshakes (DNS + TCP + TLS), compute routing (LB + serialization + app logic), and data access (RAM cache vs disk I/O). Fix the largest bucket first.

  • Cold connections hurt mobile users most

    Without edge TLS or HTTP/3 (QUIC), DNS (30ms) + TCP (1 RTT) + TLS 1.3 (1 RTT) + HTTP (1 RTT) easily burns 250–400ms before your backend runs line one.

  • Fan-out amplifies tail latency

    If one homepage call hits 8 backend services in parallel and each has a 1% chance of a slow GC pause, your user sees a slow page nearly 8% of the time (1 - 0.99^8).

  • Pool every database connection

    Opening a raw PostgreSQL connection costs 5–15ms and ~5–10MB of server RAM. Put PgBouncer in transaction mode between stateless pods and Postgres.

What Belongs at the Edge vs. Origin

Push static assets, JS bundles, product photos, and short-TTL public catalog endpoints to CDN Edge PoPs. Letting the edge terminate TLS and drop DDoS packets keeps huge CPU load completely off your Kubernetes nodes.

Send personalized mutations (checkout, cart writes, wallet debits) straight to your origin L7 Load Balancer over persistent HTTP/2 pools with mTLS. Never cache user-specific writes at a shared CDN.

Cache-Control header for high-read catalog APIshttp
HTTP/2 200 OK
Content-Type: application/json; charset=utf-8
Content-Encoding: br
Cache-Control: public, max-age=15, s-maxage=60, stale-while-revalidate=300
ETag: "sku-42-v19"
Vary: Accept-Encoding

What Breaks in Production at Each Hop

Happy-path diagrams are easy. Systems fall over in specific, repeatable ways under peak traffic:

  • Stale ISP DNS caches

    Residential ISPs routinely ignore ultra-low TTLs (<30s). Use Anycast BGP failover at the edge instead of relying on DNS edits for fast disaster recovery.

  • Cache stampede on TTL expiry

    When a viral SKU expires at 5,000 RPS, all 5,000 requests miss together and slam Postgres. Use single-flight coalescing so only one goroutine fetches from DB while others wait.

  • Hung backends behind round-robin LBs

    One deadlocked pod keeps getting 1/Nth of traffic under naive round-robin. Pair least-outstanding-requests routing with strict upstream timeouts and active /healthz probes.

Quick Capacity Math (100K RPM Product API)

A product detail API takes 100,000 requests per minute during a flash sale, with 30 KB JSON payloads (6 KB after Brotli) and a 95% Redis hit rate.

  • Traffic: 100,000 RPM = 1,667 avg RPS (3x peak burst = 5,000 RPS)
  • Redis hit ratio: 95% (5% misses hit PostgreSQL)
  • One stateless Go pod handles ~1,000 RPS comfortably under 50% CPU
  • Compressed payload: 6 KB per response
Peak Burst RPS
(100,000 / 60) × 3
5,000 peak RPS
Database QPS After Cache
5,000 RPS × 5% miss rate
250 DB QPS (1 primary + 1 replica)
App Pod Fleet (N+2 headroom)
ceil(5,000 / 1,000) × 1.5
8–10 pods across 3 AZs
Compressed Egress Bandwidth
5,000 RPS × 6 KB × 8 bits
240 Mbps (~30 MB/s)

Without Redis, Postgres takes 5,000 QPS directly and needs heavy vertical scaling or 4+ replicas. With CDN offload and a 95% Redis hit rate, 8 small pods handle 100K+ RPM easily.

Where a Request Can Terminate

Stopping reads closer to the user cuts latency by orders of magnitude, at the cost of looser freshness.

TierTypical LatencyFreshnessBest ForMain Risk
Browser Cache0–1 msTTL boundHashed JS/CSS bundles, iconsStale UI without content hashes
CDN Edge PoP8–25 msSeconds to minutesImages, SEO HTML, public catalogPurge lag on sudden price changes
Redis Cache1–3 ms (+edge)Sub-second via invalidationHot SKUs, sessions, rate limitsHot-key CPU spike or stampede
PostgreSQL12–40 ms (+edge)Strong ACIDCheckout, inventory lock, ledgerConnection exhaustion & IOPS cap

Quick Check

1. Users in Mumbai see 380ms latency hitting a US-East API, even though your backend finishes in 15ms. What single change removes the biggest chunk of cold-request latency?

2. Your product API serves 4,000 RPS at a 95% Redis hit rate. If Redis flushes all keys at once, how much does PostgreSQL read QPS jump?

Cheat Sheet

When to use it

  • Start every web-scale system design by tracing DNS -> TCP/TLS -> CDN -> L7 LB -> App -> Cache -> DB.
  • Terminate TLS at the CDN edge and keep persistent HTTP/2 pools to origin.
  • Use PgBouncer and single-flight caching whenever read traffic outstrips writes.

When to skip it

  • Never cache transactional writes (payments, stock decrements, OTPs) at a CDN edge.
  • Skip splitting stateless app servers into microservices until you hit a real team or scaling boundary.
DNS cached / cold
<1 ms / 25–60 ms
TCP + TLS 1.3
2 RTT (1 RTT HTTP/3)
In-DC Redis read
0.5–1.5 ms
Indexed SSD SQL read
5–20 ms
Cross-continent RTT
120–180 ms
Brotli JSON savings
75–85% smaller

Common mistakes

  • Skipping the TCP three-way handshake and TLS round trips when estimating mobile latency.
  • Leaving out connection pooling between stateless pods and PostgreSQL.
  • Forgetting what happens to the DB when Redis flushes or a hot key expires.

FAQ

What happens when you type a URL and press Enter?
The browser parses the URL, resolves the domain IP via DNS, completes a TCP three-way handshake and TLS 1.3 handshake, sends an HTTPS request to the CDN or L7 load balancer, gets a compressed response from app/Redis/Postgres, and renders the DOM.
How do DNS, TCP three-way handshake, and TLS 1.3 work together?
DNS turns the hostname into an IP address over UDP. Next, TCP establishes a reliable socket using SYN, SYN-ACK, and ACK (1 RTT). TLS 1.3 then verifies certificates and derives session keys in 1 RTT before encrypted HTTP bytes flow.
Why does a CDN speed up dynamic APIs even on a cache miss?
TCP and TLS handshakes take multiple round trips. Terminating TLS at an edge PoP 12ms from the user avoids crossing the ocean for handshakes, while the CDN forwards the dynamic request over already-open persistent connections to origin.
How is an L7 Load Balancer different from a CDN?
A CDN sits globally at edge locations near users to cache content, terminate TLS early, and absorb DDoS traffic. An L7 Load Balancer sits at your cloud VPC entry to inspect HTTP paths, run health checks, and balance traffic across app pods.
What is the difference between a cold and warm request?
A cold request pays full DNS, TCP, and TLS handshakes (often 100–300ms) plus a possible DB cache miss. A warm request reuses an open HTTP/2 or HTTP/3 connection and hits Redis RAM, often finishing in 20–50ms.