# What happens when you type a search into Google and press Enter?

By Vishal Kumar · Published 2026-11-13 · Updated 2026-11-13
Source: https://fungyaan.com/p/search-press-enter
Tags: system-design, networking, http, performance, distributed-systems

**Short answer:**
1. The browser turns your text into a search URL.
2. It finds Google's servers through DNS, usually from a cache.
3. It reuses or opens an encrypted connection (TLS over TCP, or QUIC).
4. It sends the request to the nearest Google edge, which forwards it over Google's own network to a data centre.
5. There, the query is understood, sent to thousands of servers that each hold a slice of the index, and the best results are merged and ranked.
6. The HTML streams back and the browser renders it while it's still arriving.

The network part takes tens of milliseconds. The real puzzle, as we'll see, is the fan-out: a request that waits for a thousand servers is as slow as the slowest one, and most of the engineering goes into not waiting for it.

Here is the case. You type, press Enter, and a page appears almost before your finger leaves the key. Yet the same page, fetched five times in a row, can take anywhere from about a tenth of a second to nearly two. Somewhere between your keyboard and the results, time goes missing. It's a question that never runs out: every step you zoom into turns out to hold its own careful piece of engineering. Let's follow one search all the way there and back, and find out where the time goes.

A word on the evidence. What's below the edge comes from Google's own published papers; how Google search works today in detail isn't public, and I've marked where I'm describing general practice. The fan-out numbers come from a simulation in [latency-debugging-lab](https://github.com/the-vishal-kumar/latency-debugging-lab) (`go run ./cmd/fanout`). The timings are real requests from my laptop.

> **Case file**
>
> | | |
> |---|---|
> | **The case** | The same page takes anywhere from about a tenth of a second to nearly two |
> | **Suspects** | DNS, the connection handshakes, the network |
> | **Culprit** | The fan-out: a request that waits for many servers is as slow as the slowest one |
> | **The fix** | Stop waiting for the slow ones: hedged requests, partial results |
> | **Evidence** | `curl` from my laptop, a fan-out simulation (`go run ./cmd/fanout`), Google's published papers |

## The scene at a glance

| Step | What happens | Typical cost | What can go wrong | How to see it |
|---|---|---|---|---|
| 1. Typing | Suggestions are fetched as you type; the address bar decides "search, not a URL" | One small request per pause | - | DevTools Network panel |
| 2. DNS | `www.google.com` → an IP address, from the browser, OS or resolver cache, or a full lookup | 0-1 ms cached; tens of ms if not | A slow or broken resolver | `dig`, `curl -w` |
| 3. Connection | TCP + TLS 1.3 handshakes, or QUIC; usually an existing connection is reused | 0 (reused) to 1-2 round trips | Packet loss on setup; a far-away server | `curl -w`, `chrome://net-export` |
| 4. Edge | The nearest front-end server ends TLS and forwards the request over Google's backbone | A few ms | - | `server: gws` header |
| 5. Search | Understand the query, fan out to index shards, merge, rank, add snippets | Most of the server time | One slow server delays the whole answer | Not visible from outside |
| 6. Response | Compressed HTML streamed back | Time to first byte, then transfer | - | DevTools Timing tab |
| 7. Rendering | Parse, style, lay out, paint; then run JavaScript | Tens to hundreds of ms on a phone | Big scripts, layout shifts | DevTools Performance panel |

```mermaid
sequenceDiagram
  participant B as Browser
  participant D as DNS resolver
  participant E as Google edge
  participant R as Root server
  participant S as Index shards
  B->>D: www.google.com?
  D-->>B: IP address (usually cached)
  B->>E: TLS or QUIC, then GET /search?q=...
  E->>R: forward over Google's backbone
  R->>S: fan out to every shard
  S-->>R: top results with scores
  R-->>E: merged, ranked page
  E-->>B: HTML streamed back
  B->>B: parse, lay out, paint
```

## 1. Before you press Enter

The first clue is that the work starts earlier than you'd think.

**The suggestions** you see while typing are separate small requests to a suggest service, sent as you type (if suggestions are on). They're the first place you meet the latency budget: a suggestion that arrives after the next keystroke is useless.

**The browser often warms up the connection.** As soon as you start typing, a browser may resolve DNS or open a connection to the search engine in advance (preconnect), so that when you press Enter there's nothing left to set up.

**When you press Enter**, the address bar decides whether you typed a URL or a search. It's a search, so the browser fills your text into the default search engine's URL template, an `https://` URL like `https://www.google.com/search?q=…`. Characters are percent-encoded, so `cheap flights` becomes `cheap+flights` or `cheap%20flights`. Because the template is already `https`, there's no insecure first request to redirect.

## 2. DNS: finding Google

The browser needs an IP address for `www.google.com`. It checks, in order: its own cache, the operating system's cache (`systemd-resolved` on my machine), then the configured resolver (your ISP's, your router's, or a public one like 8.8.8.8 or 1.1.1.1, possibly over DNS-over-HTTPS).

If nobody has it cached, the resolver walks the hierarchy: a root server, then the `.com` servers, then Google's own name servers (`ns1`-`ns4.google.com`).

Here's what I found from my laptop (Nov 2026):

```
$ dig +noall +answer www.google.com
www.google.com.   87   IN  A  142.251.150.119
www.google.com.   87   IN  A  142.251.156.119
www.google.com.   87   IN  A  142.251.153.119
```

There were several addresses, and only 87 seconds left before the cached answer expires. That short fuse is deliberate, and rather clever. Short TTLs let Google steer traffic quickly: answers can differ by where you ask from (GeoDNS), so you're sent to a nearby site, and a site can be taken out of rotation within minutes. Google's name-server records, by contrast, were cached for 241,478 seconds (almost 3 days): the delegation rarely changes.

## 3. The connection: TCP + TLS, or QUIC

This is where a couple of decades of protocol design pay off. Most of the time **there's nothing to do here**: the browser already has a connection to Google from the last search, and HTTP/2 and HTTP/3 send many requests over one connection.

When there isn't one:

| | Round trips before the request can be sent | Notes |
|---|---:|---|
| TCP + TLS 1.2 | 3 | TCP handshake, then two for TLS |
| TCP + TLS 1.3 (RFC 8446, 2018) | 2 | One for TCP, one for TLS |
| QUIC / HTTP/3 (RFC 9000, 2021; RFC 9114, 2022) | 1 | Transport and TLS 1.3 handshakes combined, over UDP |
| TLS 1.3 or QUIC with 0-RTT resumption | 0 | Request sent with the first packet to a server seen before; only for requests safe to replay |

Google advertises HTTP/3: `www.google.com` returns `alt-svc: h3=":443"; ma=2592000`. That tells the browser it can switch to QUIC for the next 30 days. On a phone with a 100 ms round trip, saving one or two round trips is worth 100-200 ms. QUIC also handles packet loss better: a lost packet holds up only its own stream, not every request on the connection, which is what TCP does.

**The evidence: first visit vs repeat visit.** My `curl` (HTTP/2 over TCP + TLS 1.3, which can't reuse anything between runs), five times:

| Run | DNS | TCP connected | TLS done | First byte | Total |
|---:|---:|---:|---:|---:|---:|
| 1 | 7 ms | 16 ms | 33 ms | 986 ms | 993 ms |
| 2 | 1 ms | 204 ms | 222 ms | 543 ms | 556 ms |
| 3 | 1 ms | 7 ms | 26 ms | 1,050 ms | 1,945 ms |
| 4 | 1 ms | 7 ms | 17 ms | 136 ms | 164 ms |
| 5 | 1 ms | 9 ms | 20 ms | 123 ms | 134 ms |

Each column is the time since the start of the request, so "TLS done" includes the DNS and TCP steps before it.

Look closely, because this table names a suspect. DNS after the first lookup was cached (1 ms), and the whole connection setup usually took 17-33 ms. Once, the TCP connect took 204 ms, probably a lost packet and a retransmit, but that's a one-off. Everything else was **waiting for the first byte**, which ranged from 123 ms to over a second for the same page. That's the homepage, not a search. And because curl doesn't run JavaScript or keep cookies, these numbers aren't what a browser sees. But the shape is typical: on a good network, the server side and its variance dominate. The network is mostly innocent. Section 5 is about why that variance exists.

## 4. The edge

The IP address you connected to belongs to a nearby Google front-end server (the response says `server: gws`; Google calls its edge layer the Google Front End). It ends TLS close to you, which keeps the handshake round trips short. It also absorbs abuse, and forwards the request over Google's private backbone to a data centre that has capacity.

The division of labour is the point, and it's a tidy one: the part that has to be near you is small, and the heavy lifting happens wherever there's room.

This is the same split you'd build with a CDN in front of your own API (the [API scaling post](/p/scale-an-api) covers that side): end the connection near the user, then move the request over a better network than the public internet.

## 5. The search itself: the fan-out, and the real culprit

*This section follows Google's published papers: "Web Search for a Planet" (Barroso, Dean, Hölzle, IEEE Micro, 2003) and "The Tail at Scale" (Dean, Barroso, CACM, 2013). Today's system is more elaborate, but the structure they describe is how large search systems are built.*

1. **Understand the query:** spelling correction, synonyms, language, location, whether it's a question, a product, a place.
2. **Look it up in the index.** The index (for every word, the documents that contain it) is far too big for one machine, so it's **split into shards**: each shard holds the index for one slice of the documents. Every shard must be asked, because any slice might hold the best result. Each shard is copied to many replicas, for capacity and to survive failures.
3. **Fan out and merge.** A root server sends the query to an aggregator per group of shards. Each aggregator asks its shards, and each shard returns its top few results with scores. The aggregators merge them, and the root merges again. One query touches thousands of machines.
4. **Rank, then build the page:** final ranking, snippets from the document servers, ads (an auction running in parallel), spelling suggestions, and other result types. Popular queries can be answered from a cache of recent results.

Here's where the case turns. The strength of this design is that no single machine has to be big; the cost is that every query now depends on thousands of them.

**The clue: why the slowest server decides.** If one request waits for *N* servers, and each server is slow 1% of the time (a GC pause, a busy neighbour, a queue behind a big request), then the chance that *at least one* is slow is 1 - 0.99^N. I simulated it: each leaf usually answers in about 1 ms, but 1% of the time takes about 50 ms:

| Servers per request | p50 | p99 | Requests slower than 10 ms | 1 - 0.99^N |
|---:|---:|---:|---:|---:|
| 1 | 1.0 ms | 40.8 ms | 1.0% | 1.0% |
| 10 | 1.5 ms | 57.8 ms | 9.0% | 9.6% |
| 100 | **46.2 ms** | 59.8 ms | **63.6%** | 63.4% |
| 1,000 | 58.6 ms | 60.0 ms | 100% | 100% |

```mermaid
xychart-beta
  title "Median (p50) latency vs servers per request (ms)"
  x-axis ["1", "10", "100", "1,000"]
  y-axis "p50 (ms)"
  bar [1.0 , 1.5 , 46.2 , 58.6]
```

At 100 servers, a hiccup that affects 1% of calls makes **most requests** slow: the *median* is now the slow case. At 1,000, every request is slow. That's the culprit, hiding in plain arithmetic. And here's the false lead most people chase: you can't fix this by making each server faster on average. You have to stop waiting for the slow ones. With 100 servers:

| Strategy | p50 | p99 | Slower than 10 ms | Extra cost |
|---|---:|---:|---:|---|
| Wait for all | 46.2 ms | 59.8 ms | 63.6% | - |
| **Hedge:** if a server hasn't answered in 2 ms, ask another replica too, and take the first answer | 2.9 ms | 4.3 ms | 1.0% | 1.3% more requests |
| **Partial results:** answer at 5 ms with whatever has arrived | 5.0 ms | 5.0 ms | 0% | 1% of shards missing from the answer |

This is the reveal, and it's a beautiful one. Hedging after roughly the 95th-percentile response time removes almost all of the tail for a percent or two of extra load. That's the "hedged requests" technique from *The Tail at Scale*, and it's the paper's most practical idea: rather than fighting randomness, you spend a little extra work to step around it. Answering with partial results bounds latency outright, at the cost of occasionally missing a shard's results, which a search engine can afford and a bank can't. Both ideas apply far beyond search: any API that calls several services in parallel and waits for all of them has the same problem.

*Simulated, not measured: the leaf latency model is stated in the code and every number above is reproducible from its seed.*

## 6. The response

The results page comes back as compressed HTML (Brotli or gzip), **streamed**: the server can send the top of the page (header, styles, search box) before ranking has finished, so the browser starts work early. Styles needed for the first screen are often inlined, so no extra request blocks rendering. Images and scripts the page needs later are loaded after, or lazily.

## 7. Rendering

The browser parses the HTML into the DOM and the CSS into style rules, works out the layout, and paints. Results can appear before every script has loaded. JavaScript then makes the page interactive and loads extras. On a fast laptop this is a few tens of milliseconds; on a mid-range phone it's often the biggest part of what you feel. The measurements that matter here are the Core Web Vitals: when the main content appears (LCP), how quickly the page responds to input (INP), and whether things jump around (CLS). The [lag-debugging post](/p/debug-slow-page) covers how to find what's slow in this layer.

## A second case: the same search on a slow mobile network

On a phone with a 150 ms round trip, the arithmetic changes, and so does the suspect. A new TCP + TLS 1.3 connection costs 300 ms before the request leaves; QUIC costs 150 ms, and 0-RTT costs nothing. Every extra request the page makes, for a script or a font, adds at least one round trip. That's why fast sites:
- keep connections open, and use HTTP/3;
- keep the first screen's critical resources small and inline;
- push work from the phone back to the server.

On a phone, the network and rendering costs usually outweigh the server's.

> **Remember this**
> - On a good network, the server side and its variance dominate.
> - Waiting for many servers makes the slowest one decide.
> - Hedge or answer with partial results instead of waiting for all.

## What to take back to your own systems

- **Count round trips, not only bytes.** Reuse connections, consider HTTP/3 at your edge, and avoid chains of dependent requests.
- **End connections close to users.** A CDN or edge proxy shortens the handshakes and can cache.
- **Use short DNS TTLs** on records you might need to move quickly, and long ones on records that don't change.
- **If one request waits for many servers, design for the tail:** timeouts, hedged requests, partial answers where they're acceptable, and p99 on every dashboard.
- **Stream responses** so the client can start before you've finished.

The next time a results page appears before you've lifted your finger off Enter, it's worth a moment's appreciation: thousands of machines, a handful of round trips, and a lot of people who refused to wait for the slowest server.

*DNS and `curl` timings: my laptop's connection, Nov 2026, curl 8.18 (HTTP/2; curl doesn't use HTTP/3 here). Fan-out: a simulation with a stated model (latency-debugging-lab, `cmd/fanout`). Google internals: Barroso, Dean and Hölzle (IEEE Micro, 2003) and Dean and Barroso (CACM, 2013); current details are not public. Protocols: RFC 8446 (TLS 1.3), RFC 9000 (QUIC), RFC 9114 (HTTP/3).*
