Skip to main content
Latency Waterfall
p50 · p90 · p99 · p99.9 per hop

Search Autocomplete: Latency Waterfall

Break down end-to-end latency by hop and percentile. Understand where the p99 tail comes from — DNS, network, cache lookup, database query, serialization. Real requests have wildly different paths depending on cache-hit location.

Back to Search Autocomplete

Latency Waterfall

Break down end-to-end latency by hop (network, application, database, cache) and percentile (p50/p90/p99/p99.9). Real requests have wildly different paths depending on cache-hit location — pick a scenario to see the full waterfall.

Amara Google 2009: every 100ms of latency = 1% revenue lost. Understanding WHERE the tail comes from is the difference between random optimization and targeted engineering.

Show percentile:
Aggregate p99: 468.0 ms

Cached prefix — CDN edge hit (~65% of traffic)

User types common prefix ('goo'). CDN edge cache hit. Sub-30ms end-to-end.

65% of requests
Client: debounce (300ms delay)
application
300.0 ms
p50 300msp90 300msp99 300msp99.9 300ms

Client-side debounce. User types → wait 300ms after last keystroke → send query.

Optimize: Debounce is CRITICAL. Without it, user typing 'google' sends 6 queries. With debounce, 1 query for 'google'.

Client → CDN edge: autocomplete request
network
80.0 ms
p50 10msp90 30msp99 80msp99.9 300ms

Small payload, HTTP/2 keep-alive.

CDN edge: cache hit for prefix
cache
8.0 ms
p50 1msp90 3msp99 8msp99.9 30ms

Popular prefixes ('goo', 'ama') cached at edge with 30s TTL.

CDN edge → Client: suggestions
network
80.0 ms
p50 10msp90 30msp99 80msp99.9 300ms

Small JSON response with top-10 suggestions.

End-to-end aggregate
p50 321.0 ms
p90 363.0 ms
p99 468.0 ms
p99.9 930.0 ms
Key insight

Cache-hit path is **~30ms p99** (excluding client debounce). Sub-20ms server-side budget met with edge caching. **Debounce is the single most important optimization** — 6x fewer requests, better UX, less server load.

Scenario 1 of 3

Bottleneck summary

Autocomplete latency is **DOMINATED BY CLIENT DEBOUNCE** (300ms — always). Server-side is 30-200ms depending on cache hit. **Amara paper 100ms = 1% revenue lost is the reference metric**. FST data structure (5-10x smaller than Trie) enables sub-10ms server-side lookups. Edge caching for popular prefixes + FST server for tail = balance between hit rate and freshness.

Optimization tips (this architecture)

  • **Client-side debounce (300ms)**: CRITICAL. Without it, 6x more requests. With it, better UX + less load.
  • **Edge cache popular prefixes (30s TTL)**: 65%+ hit rate. Sub-30ms end-to-end.
  • **FST vs Trie**: 5-10x smaller in memory. Fits 1M+ suggestions in <1GB RAM per shard.
  • **Flink 60s trending overlay**: Real-time trending queries blend with base suggestions. Refresh every 15s.
  • **Prefix hash sharding**: Route by prefix hash to specific FST shard. Even distribution.
  • **Personal L1 cache for premium**: Recent queries per user for personalization. Bypass edge cache.
  • **HTTP/2 keep-alive**: Persistent connection eliminates handshake per keystroke.
  • **Small payloads**: JSON responses <2KB. Compression optional (already small).

Where to go next

Now that you can see where latency comes from, trace how the architecture EVOLVES to handle 10x more traffic. Or dive into the masterclass for the full ADR + business exercise + incident narrative.