Latency Numbers
These numbers are for building intuition, not for benchmark claims. Every figure below is an order of magnitude and shifts with hardware, kernel, network and load. The value of knowing them is that you can tell a 10-millisecond design from a 10-second one in your head.
The 60-second answer
Section titled “The 60-second answer”Memory is nanoseconds, SSD is tens to hundreds of microseconds, a datacenter round trip is about half a millisecond, and a cross-continent round trip is over a hundred. Disk seeks and network round trips dominate everything you do; the number of round trips matters more than the cost of any single operation. Averages hide the tail, so design for p99. Fan-out multiplies tail latency across services. So optimise in this order: reduce round trips, cache, parallelise, batch, and only then micro-optimise code.
The table
Section titled “The table”| Operation | Rough latency | Notes |
|---|---|---|
| L1 cache hit | ~1 ns | On-die; not your bottleneck |
| Branch misprediction | a few ns | Why branchy hot loops are slower |
| L2 cache hit | ~5 ns | Still negligible for app code |
| Mutex lock/unlock (uncontended) | ~10–20 ns | Contention is the real cost |
| Main memory (RAM) reference | ~100 ns | One cache miss ≈ 100× an L1 hit |
| Compress 1 KB (fast algorithm) | ~1–3 µs | Depends entirely on the codec |
| Send 1 KB over a 1 Gbps link | ~10 µs | Serialisation, not distance |
| Read 1 MB sequentially from RAM | ~100–250 µs | Memory bandwidth |
| Read from SSD (random, 4KB) | ~50–150 µs | NVMe; spinning disk is far worse |
| Round trip within one datacenter | ~0.5 ms | Two services talking |
| Read 1 MB sequentially from SSD | ~1 ms | Faster than the network for large blocks |
| Database commit (fsync, local SSD) | ~1–10 ms | The durability tax |
| Disk seek (spinning) | ~5–10 ms | Why random IO on HDD is fatal |
| Send a packet CA → Netherlands → CA | ~100–150 ms | Speed of light plus routing |
| Cross-continent TCP + TLS handshake | ~3× that RTT | Each round trip is paid |
Derived numbers worth memorising:
- Speed of light in fibre is roughly 200 km/ms (two-thirds of
c), and real routes are longer than the great-circle distance. That is why a transatlantic round trip cannot be much under 70–80 ms. - A new HTTPS connection to a distant region costs several RTTs before the first byte of the response. This is the entire argument for CDNs, connection pools and keep-alive.
- Memory is ~100× faster than SSD random reads, and SSD is ~100× faster than a disk seek. Three orders of magnitude each, which is the whole story of cache hierarchies.
Throughput vs latency
Section titled “Throughput vs latency”They are different axes and often trade against each other.
- Latency is how long one request takes: measured as p50, p95, p99, max.
- Throughput is how many complete per unit time: rps.
- Batching improves throughput (amortised overhead) and worsens latency (waiting for the batch).
- Concurrency improves throughput until a shared resource saturates, then latency collapses.
A system can have high throughput and terrible latency: a queue with a huge backlog drains at 10,000/s while every individual item waits minutes. Always state which one the requirement is about.
Little’s Law
Section titled “Little’s Law”L = λ × WConcurrency L equals arrival rate λ times time in system W. It is exact for a stable system
and it is the most useful formula in capacity planning.
λ = 5,000 requests/sW = 0.2 s averageL = 1,000 requests in flight
If each request holds a database connection for its full duration,you need ~1,000 concurrent connections, not 20.The inverse is how you diagnose a pool: if your pool has 50 connections and each query takes 5 ms,
your ceiling is about 50 / 0.005 = 10,000 queries/s. Beyond that, requests queue — and queueing
time, not service time, becomes your latency.
Tail latency
Section titled “Tail latency”Averages are useless for user experience. If 1% of requests take 2 seconds, the average looks fine and 1 in 100 users has a bad time. Worse, the tail is caused by real events: GC pauses, cache misses, retries, noisy neighbours, slow disks, deploys.
Fan-out amplification. A page that calls 20 services in parallel, each with a 1% chance of
being slow, has a 1 - 0.99^20 ≈ 18% chance of being slow. Tail latency compounds
multiplicatively with fan-out, which is the core argument for hedged requests, timeouts with
fallbacks, and reducing dependencies per page.
Coordinated omission. A naive load generator sends a request, waits for the response, then sends the next. When the server stalls, the generator stalls too, so the stall is not counted. Real users do not pause; they keep arriving. This makes benchmark p99s look far better than production.
Timeouts and retries. A timeout of 1 second with two retries means a 3-second user experience in the worst case, and triples load on a struggling dependency. Bound the total budget, not each attempt.
Percentile aggregation. You cannot average p99s across machines. You must merge histograms, or accept that the aggregate is wrong. This is why metrics backends store histograms, not scalar percentiles.
Optimisation order
Section titled “Optimisation order”Do these in order; each is roughly an order of magnitude:
- Measure. Find the p99 and the slowest dependency. Optimising the wrong thing is free of benefit and not free of risk.
- Reduce round trips. N+1 queries, chatty service calls, sequential dependent fetches. This is usually the biggest win and is invisible in CPU profiles.
- Cache. Memory and edge caches remove the work entirely. See Caching.
- Parallelise. Independent calls in flight together:
Promise.all,Future/Task, or a fan-out in the handler. - Batch and pipeline. One round trip for 100 rows instead of 100 round trips.
- Denormalise / precompute. Move work to write time or to a background job.
- Scale out. More replicas, more shards.
- Micro-optimise. Algorithmic complexity, allocations, serialisation format. Real, but the smallest lever for a typical web service.
Applying it in an interview
Section titled “Applying it in an interview”When you estimate, translate the numbers into round trips:
Requirement: 100 ms p99 for a redirect.Budget: TLS (already warm) 0 ms, app 5 ms, Redis 0.5 ms, DB (on miss) 5 ms.Remaining: fine. But if the design calls 5 sequential services at 0.5 ms each,plus a 5 ms DB read on every request, the p99 will not hold under fan-out.Saying “each cross-service call costs about half a millisecond in-region, so five sequential calls is 2.5ms at p50 and more at p99” is exactly the kind of concrete reasoning interviewers reward.
Follow-up questions
Section titled “Follow-up questions”- Why is a datacenter round trip ~0.5ms and not ~0.05ms?
- Your p50 is 20 ms and p99 is 2 s. What are the likely causes?
- How does fan-out of 10 services at 1% slow each change the user-visible failure rate?
- Using Little’s Law, how many connections do you need for 2,000 rps at 100 ms?
- Why can batching improve throughput and hurt latency at the same time?
- What is coordinated omission and why does it matter for benchmarks?
Common traps
Section titled “Common traps”- Treating the numbers as exact. They are orders of magnitude. Say “about” and give a range.
- Optimising CPU when the problem is round trips. Most slow endpoints are N+1 or sequential calls, not slow code.
- Quoting the average. Users experience the tail. Report p95/p99.
- Ignoring the handshake. A cold connection to another region can cost more than the work.
- Assuming a cache hit is free. A remote cache hit is a network round trip; a local computation may be faster.