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

Distributed Logging System: 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 Distributed Logging System

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: 1320.0 ms

Hot query — recent logs (last 24h) (~85% of queries)

Engineer searches logs from last 24h in Kibana. Data in hot SSD tier.

85% of requests
Kibana → ES coord
network
200.0 ms
p50 30msp90 80msp99 200msp99.9 600ms

User query submitted.

Coord: parse query + fan out
application
40.0 ms
p50 5msp90 15msp99 40msp99.9 120ms

Query planning.

20 data shards: parallel Lucene execution
database
800.0 ms
p50 100msp90 300msp99 800msp99.9 3000ms

Full-text search across shards.

Optimize: Time-based indices (daily) reduce shards to search.

Coord: merge results
application
80.0 ms
p50 10msp90 30msp99 80msp99.9 300ms

Merge sorted results.

Coord → Kibana: response
network
200.0 ms
p50 30msp90 80msp99 200msp99.9 600ms

Rendered.

End-to-end aggregate
p50 175.0 ms
p90 505.0 ms
p99 1320.0 ms
p99.9 4620.0 ms
Key insight

Hot query is **~500ms-1.5s p99**. Full-text search dominant. Time-based indices help — only search relevant days.

Scenario 1 of 3

Bottleneck summary

Logging latency has two profiles: **hot query (~500ms-1.5s)** and **cold query (seconds to minutes)**. Ingest is ~100-500ms end-to-end. **The critical trade**: storage tiers optimize cost 10x but slow cold queries. Time-based indices + label-based routing (Loki) reduce query cost.

Optimization tips (this architecture)

  • **Time-based indices**: Daily indices. Query only relevant days.
  • **Tiered storage**: 7d hot + 90d warm + Glacier cold. 60 pct cost savings.
  • **Kafka buffer**: Absorbs ingest spikes.
  • **Logstash pipeline optimization**: Reduce enrichment overhead.
  • **ES refresh interval**: 30s for high-volume (not default 1s).
  • **Loki for cost-sensitive workloads**: Label-based indexing = 10x cheaper.
  • **Warm-cache before compliance**: Pre-hydrate S3 tier.
  • **Query result caching**: Repeated dashboard queries served from cache.

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.