Latency Explained: p99, Latency Budgets & Numbers Everyone Should Know (3:36)

  1. 0:00 Why does p99 matter more than the average?
  2. 0:10 That wait = latency
  3. 0:21 The 4 parts of latency
  4. 0:46 Queueing: the sneaky part
  5. 1:04 Percentiles: p50 vs the tail
  6. 1:29 Latency numbers to know
  7. 1:56 A 300 ms p99 latency budget
  8. 2:20 Over budget? Find the part, apply the fix
  9. 2:39 Recap + interview questions
  10. 3:07 Free notes + what's next

Lesson 08: Latency

Roadmap

You are in System Design Interview Prep, Track 01, Core Fundamentals: lesson 8 of 19 (p99, latency budgets and the numbers to know). It builds on Lesson 07: Horizontal Scaling. Next comes Lesson 09: Throughput and Little's Law.

These are the written notes for the lesson's video. Prefer paper? The same notes are a free, printable PDF: download SD-A-008.pdf.

Concept

Key idea

Latency is the time for one request, made of network, queueing, processing and I/O; measure it as percentiles, know the key numbers, and split the target into a budget per component.

Explanation

What latency is made of

Latency is the time from sending a request to receiving the full response. It's never one thing; it's the sum of four parts, and each part has different fixes.

The four parts of latency. Queueing is the sneaky one: it grows fast near full utilization, even when your code doesn't get slower.

Figure 1. The four parts of latency. Queueing is the sneaky one: it grows fast near full utilization, even when your code doesn't get slower.

Measure percentiles, not averages

p50 is the typical request; p95 and p99 are the slow tail. If one page calls 10 services, the chance that at least one call is at or beyond its p99 is 1 − 0.9910 ≈ 10%. With 50 calls it's ~40%. The tail is what users actually feel.

Numbers every engineer should know

Operation Typical time Relative to memory
Read from main memory ~100 ns 1×
Random read from an SSD ~100 µs ~1,000×
Round trip inside one data centre ~0.5 ms ~5,000×
Read 1 MB sequentially from an SSD ~1 ms ~10,000×
Round trip across regions (e.g. India ↔ Europe) 100–150 ms ~1,000,000×

Rough orders of magnitude are enough: they tell you instantly that a cross-region call inside a loop is a bad idea, and that caching in memory beats any disk.

Latency budgets

A 300 ms p99 target split into a budget per component. Every team knows its number.

Figure 2. A 300 ms p99 target split into a budget per component. Every team knows its number.

If a part goes over budget, you know where to look, and each fix maps to one part of latency:

Too much … Fix
Network Move closer to users (CDN, regions), cut round trips, batch calls
Queueing Add capacity, lower utilization, shed low-priority load
Processing Profile hot code, do less work per request, move work to async jobs
I/O / database Add an index, cache hot reads, avoid N+1 queries

Key terms

Term Meaning
Latency time for one request
p99 99% of requests are faster
Tail latency the slowest few percent
Queueing delay time waiting for a free worker
Latency budget max time per component
RTT round-trip time

Interview questions

Each question is tagged by kind: Basic (definitions), Scenario (apply it to a system) and Tricky (the follow-ups interviewers use to go deeper). Answer out loud before you open the answer.

Interview

Why use p99 instead of the average? (Basic)

What a strong answer covers

Averages hide the slow tail, and pages make many calls, so most users hit some call's p99 regularly. Percentiles show what users actually feel.

Interview

How does a cross-region round trip compare with a memory read? (Basic)

What a strong answer covers

Roughly 100 ms versus 100 ns: about a million times slower.

Interview

What are the parts of latency? (Basic)

What a strong answer covers

Network time, queueing (waiting for a worker), processing (your code) and I/O (disks, databases). Each has different fixes.

Interview

Your API's p99 jumped from 120 ms to 900 ms but code didn't change. Where do you look? (Scenario)

What a strong answer covers

Queueing and dependencies: higher utilization, a saturated pool or a slow database. Check traffic, CPU, pool wait time and database latency, using traces to see which span grew.

Interview

Split a 300 ms p99 budget for a checkout request. (Scenario)

What a strong answer covers

Gateway ~20 ms, service logic ~80, cache ~10, database ~120, and ~70 for network and headroom. Then each team owns its number.

Interview

A page calls 5 services one after another, each 60 ms. How do you speed it up? (Scenario)

What a strong answer covers

Call independent services in parallel (≈ 60 ms instead of 300), cache results that change rarely, or have one aggregator call them inside the data centre.

Interview

With 10 calls per page, why do ~10% of pages hit a p99? (Tricky)

What a strong answer covers

Each call has a 1% chance of being in its slowest 1%. The chance at least one of 10 is: 1 − 0.9910 ≈ 9.6%.

Interview

Can adding a cache make p99 worse? (Tricky)

What a strong answer covers

Yes, if misses add a network hop before the database, or the cache is overloaded or cold after a restart. Measure hit rate and miss latency, and warm caches after deploys.

Common mistakes & troubleshooting

  • Reporting average latency.
  • Calling services one after another when they could run in parallel.
  • Ignoring cross-region round trips in the design.
  • Measuring latency without stating the load it was measured at.

Free PDF notes

Download these notes as a printable PDF, with every diagram: SD-A-008.pdf. All Phase 1 notes in one file: Phase 1, Core Fundamentals (PDF).

The Phase 2 video on this page has its own notes: SD-D-002: Latency Numbers & Powers of Two Every Engineer Should Know. All of them in one file: Phase 2, Estimation (PDF).

Next

Continue with Lesson 09: Throughput and Little's Law.