← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

Tail Latency (p95, p99)

performance Advanced

Also Known As

p99 latency p95 latency long tail latency percentile latency

TL;DR

The latency experienced by the slowest requests — p99 is the response time below which 99% of requests fall, the most user-visible metric.

Explanation

Average latency hides the experience of slow requests. Percentile metrics reveal tail behaviour: p50 (median), p95 (95% of requests are faster), p99, p99.9. At scale, tail latency is user-impacting — if p99 is 2 seconds and you serve 1,000 requests per second, 10 users per second experience that delay. Tail latency causes include: garbage collection pauses, lock contention, slow database queries, cold OPcache, and resource starvation. Monitor percentiles in production (Prometheus, Datadog, New Relic), set SLOs against p99, and alert when they breach thresholds rather than when averages rise.

Common Misconception

Average response time is the key metric for measuring application performance. Average latency hides outliers — a p99 of 5 seconds means 1% of users wait 5+ seconds. At scale, every user experiences the tail eventually. Monitor p95/p99 percentiles, not just averages.

Why It Matters

The 99th percentile latency (P99) represents the slowest 1% of requests — in a microservice chain where 10 services each have 1% slow requests, roughly 10% of user requests will be slow.

Common Mistakes

  • Monitoring only average latency — averages hide tail latency completely.
  • Not setting per-request timeouts — one slow downstream call raises P99 for all requests waiting on it.
  • Unbounded retries that amplify tail latency — a slow response retried 3 times triples the latency.
  • Not hedging requests — sending a duplicate request to a second server after a threshold eliminates most tail latency.

Code Examples

✗ Vulnerable
// Monitoring average — hides P99 problems:
$avg = array_sum($latencies) / count($latencies); // 50ms average looks fine
// But P99 might be 2000ms — 1% of users see 2s loads

// Measure percentiles:
sort($latencies);
$p99 = $latencies[(int)(count($latencies) * 0.99)];
✓ Fixed
// Hedged requests — if P99 latency is high, send a second request
// after a short delay and use whichever responds first
function hedgedFetch(string $url, int $hedgeAfterMs = 100): mixed {
    $primary   = asyncFetch($url);
    $secondary = delay($hedgeAfterMs)->then(fn() => asyncFetch($url));
    return race([$primary, $secondary]); // first to resolve wins
}

// Measure percentiles — averages hide tail latency
// p50=10ms, p99=800ms means 1% of users wait 80x longer
// Use Prometheus histograms or StatsD timers to expose percentiles
$histogram->observe($responseTimeMs); // not just average

// Common tail latency causes: GC pauses, lock contention, network jitter
// Mitigation: timeouts + retries with jitter, connection pooling, async I/O

Added 15 Mar 2026
Edited 22 Mar 2026
Views 22
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings F 0 pings S 2 pings S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 3 pings S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 1 ping S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 1 ping S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S
No pings yet today
No pings yesterday
Amazonbot 6 Perplexity 5 Unknown AI 2 Google 2 Majestic 1 Ahrefs 1
crawler 16 crawler_json 1
DEV INTEL Tools & Severity
🟠 High ⚙ Fix effort: Medium
⚡ Quick Fix
Measure p99 and p99.9 latency alongside averages — averages hide tail latency; set your SLO at p99, alert at p95, and investigate any endpoint where p99 is >5x the p50
📦 Applies To
any web api
🔗 Prerequisites
🔍 Detection Hints
Only average response time tracked; no percentile metrics; SLO defined in averages not percentiles; tail latency not visible in monitoring
Auto-detectable: ✓ Yes datadog prometheus grafana opentelemetry
⚠ Related Problems
🤖 AI Agent
Confidence: Medium False Positives: Medium ✗ Manual fix Fix: High Context: File

✓ schema.org compliant