Performance engineering cheat sheet
One page for the day before a performance interview: the formulas with worked numbers, the figures worth knowing, method checklists for the common prompts, and twenty-four questions with short answers that point to the lessons.
GuideCore15 min readUpdated
- 4 self-checks
On this page7 sections
Read first: Latency, throughput and queues, Load testing and benchmarking, Profiling and finding the bottleneck, Tail latency and overload, Network performance for system designers, Observability: metrics, logs and traces, SLOs, error budgets and alerting
- Recall the formulas for queues, scaling, statistics and networks, and do each with real numbers.
- Quote the latency, packet and protocol figures that interviewers expect, and label them as rules of thumb.
- Turn an SLO into minutes of error budget and a burn-rate alert, and estimate series and trace volume.
- Run a method checklist for a slow service, a load test, regression detection, overload, alerting and a slow transfer.
- Answer the twenty-four most common performance questions in a sentence or two, then go deeper.
This page is for revision, not for learning. Every formula below is derived and tested in a lesson of this section, and the last table says which one to open when an answer does not feel obvious. The habit that wins these interviews is the same each time: say the formula, put numbers in it, state the assumption, then say what you would do.
Queues, capacity and scaling
| Name | Formula | Use it to | Worked example |
|---|---|---|---|
| Little's Law | L = λ × W | Size pools, check a benchmark | 2,000 requests/s × 0.05 s = 100 in flight |
| Utilization law | U = X × D ÷ m, so a resource is full at X = m ÷ D | Find each resource's ceiling | 2 ms of CPU on 8 cores: 4,000/s. A 0.45 ms global lock: 2,222/s, the bottleneck |
| M/M/1 response time | S ÷ (1 − ρ) | Predict the hockey stick | S = 10 ms at 80% busy: 50 ms mean |
| M/M/1 tail | p99 is about 4.6 × the mean | Turn a mean into a tail | 50 ms mean: about 230 ms p99 |
| Kingman | wait ≈ ρ ÷ (1 − ρ) × (ca² + cs²) ÷ 2 × S | See why variability matters | Constant service times wait half as long as exponential ones |
| Utilization for a target | ρ ≤ 1 − 1 ÷ k for a mean within k × S | Set headroom | k = 3: run at 67% or less |
| Headroom for failure | normal peak ≤ target × (N − 1) ÷ N | Size zones | 75% after losing one of 3 zones: 50% on a normal day |
| Amdahl | speedup ≤ 1 ÷ (s + (1 − s) ÷ N) | Bound a fix | 5% serial: never above 20×. A 45% frame: at most 1.8× |
| Universal Scalability Law | C(N) = N ÷ (1 + α(N − 1) + βN(N − 1)), peak at √((1 − α) ÷ β) | Explain flat or falling scaling | α = 0.05, β = 0.001: 5.7× at 8 workers, a peak near 31 workers at 9× |
| Fan-out tail | 1 − (1 − p)^n | See why p99 matters | 1% slow, 100 calls: 63% of requests |
| Fleet size | runs per day × minutes per run ÷ 1,440 ÷ target utilization | Size a pool | 3,880 runs × 10 min ÷ 1,440 ÷ 0.7 = 39 hosts |
| Retry amplification | attempts ^ layers | Cap retries | 3 attempts in 5 layers: 243 on the bottom one |
Measurement and statistics
| Name | Formula | Use it to | Worked example |
|---|---|---|---|
| Interactive response time | N = X × (R + Z) | Check a closed-loop test | 50 users, no think time, 2 ms: expect 25,000/s |
| Runs needed | n ≈ 16 × (σ ÷ δ)² per side | Plan a comparison | 2% target: 4 runs at 1% noise, 36 at 3%, 64 at 4% |
| Samples for a percentile | ten samples beyond p99.9 need 10,000 requests | Trust a tail number | A p99 from 200 requests rests on two samples |
| Multiple comparisons | false alarms ≈ benchmarks × significance level | Design a gate | 100 benchmarks at 5%: about 5 per change |
| Bisect cost | log2(commits) measurements | Cost of finding a culprit | 63 commits: 6. 1,000 commits: about 10 |
| Frame share to gain | 1 ÷ (1 − share) | Prioritize | A 20% frame can buy 1.25× at most |
| CPU quota throttling | frozen = period − quota ÷ busy threads, quota = limit × period | Explain container p99 steps | 2 CPUs, 8 busy threads, 100 ms period: frozen 75 ms |
| Key skew | Zipf with s = 1 | Model hot keys | 10,000 keys: the hottest 1% take 53% of requests |
| Error budget | (1 − SLO) × window | Turn a target into minutes | 99.9% over 30 days: 43.2 minutes. 99.99%: 4.3 |
| Budget used by a burn rate | burn × window ÷ SLO window | Size a burn-rate alert | 14.4 over 1 hour: 2% of a 30-day budget. 6 over 6 hours: 5% |
| Availability in series | a ^ n | Cap an SLO by its dependencies | Three at 99.9%: 99.7%. Ten: 99.0% |
| Series a metric can create | the product of the values of each label | Estimate a metrics bill | 25 × 4 × 5 × 6 × 50 labels: 150,000. As a histogram, 15 times more |
Network and packets
| Name | Formula | Use it to | Worked example |
|---|---|---|---|
| Propagation | 5 µs per km each way in fiber | Find the latency floor | New York to London, 5,570 km: about 56 ms round trip |
| Round trips to first byte | TCP + TLS 1.2: 4. TCP + TLS 1.3: 3. QUIC: 2. QUIC 0-RTT: 1. Reused connection: 1 | Cost of a new connection | At 80 ms: 320, 240, 160, 80 and 80 ms |
| Bandwidth-delay product | bandwidth × RTT | Find the window needed | 1 Gbps × 80 ms = 10 MB |
| Window-limited rate | window ÷ RTT | Explain a stuck transfer | 64 KB at 80 ms: 6.6 Mbps. 4 MiB: 420 Mbps |
| Slow start | rounds n with 10 × (2^n − 1) ≥ segments | Time a short transfer | 100 KB: 3 round trips. 1 MB: 7. 10 MB: 10 |
| Loss-limited rate | (MSS ÷ RTT) × (C ÷ √p), C about 1.2 | Explain a long, lossy path | 1,460 B, 80 ms, 0.01% loss: about 18 Mbps |
| Queue delay | buffer × 8 ÷ link rate | Spot bufferbloat | 1 MB at 10 Mbps: 800 ms |
| Packet rate | bits per second ÷ ((frame + 20) × 8) | Start a data plane budget | 10 Gbps of 64-byte frames: 14.88 M packets/s. 1,518-byte: 0.81 M |
| Cycle budget | Hz × cores ÷ packets per second | Budget per packet | One 3 GHz core at 10 Gbps of 64-byte frames: about 200 cycles. 16 cores, 100 Gbps, 362-byte mix: about 1,470 |
| Payload share | payload ÷ (payload + 78) | Judge small-message overhead | 1,460 B: 95%. 100 B: 56% |
These are rules of thumb and vary by hardware and version. Say "about", and say they are rules of thumb.
| Item | Figure |
|---|---|
| Light in fiber | About 200,000 km per second |
| CPU cache read | 1 to 10 ns |
| Main memory read (a cache miss) | About 100 ns, or about 300 cycles at 3 GHz |
| Random read from a fast SSD | 50 to 100 µs |
| Round trip inside a datacenter | About 0.5 ms |
| Spinning-disk seek | 5 to 10 ms |
| Round trip between continents | 100 to 150 ms |
| Ethernet frame on the wire | Frame size + 20 bytes. MTU 1,500, MSS 1,460 |
| TCP initial window | 10 segments, about 14.6 KB. The window field alone is 65,535 bytes without scaling |
| Delayed ACK on Linux | About 40 ms minimum (200 ms maximum). The Nagle stall is about 40 ms |
| Linux connection limits | About 28,000 ephemeral ports, TIME_WAIT of 60 s, often 1,024 open files |
| Container CPU period | 100 ms by default |
| CoDel defaults (Linux) | Target 5 ms, interval 100 ms |
| Profiler sampling | 99 Hz, not 100 |
| Hedged request | After about the p95: about 5% extra requests |
| Error budget of 99.9% | 43.2 minutes in 30 days. 99.99%: 4.3 minutes. 99.999%: 26 seconds |
| Burn-rate alert policy | Page at 14.4 over 1 hour (and 5 minutes) and 6 over 6 hours (and 30 minutes). Ticket at 1 over 3 days (and 6 hours) |
| SRE client throttle | Reject with probability max(0, (requests − K × accepts) ÷ (requests + 1)), K = 2 |
| gRPC retry throttling | A token bucket: a failure costs 1, a success returns a fraction, no retries at or below half |
When the service is slow
- Make the symptom precise: endpoint, percentile, start time, what changed.
- Inside the service or not? Compare client-side and server-side latency.
- Run USE (utilization, saturation, errors) on every resource, pools and locks included.
- Choose the profiler: CPU, off-CPU, allocation or trace.
- Bound the gain with Amdahl, predict, change one thing, measure again, add a guard.
See profiling and finding the bottleneck.
When you design a load test
- Write the question and the pass condition first.
- Open loop where clients are independent; measure from the intended send time.
- Realistic mix, connections, key skew, data size and dependency latency.
- Check the generator, warm up, run long enough, and report capacity at an SLO.
- Compare builds with per-run values, interleaving, an interval and a minimum effect.
See load testing and benchmarking.
When you detect regressions in CI
- Tier the tests; select by changed paths; batch and bisect.
- Measure each benchmark's noise; gate only on stable ones and quiet metrics.
- Detect sustained shifts with change points, not a threshold on one run.
- Bisect the batch, confirm with a direct A/B, send the owner a ticket with evidence.
- Track precision, and watch for slow creep against fixed anchors.
See the performance testing platform.
When the service is overloaded
- Stop the loop first: shed load, cut retries and hedging, drop optional work.
- Bound queues, propagate deadlines, drop expired requests.
- Shed by priority and cost, early and cheaply; protect established work.
- Retry in one layer with a budget; throttle on the client; let limits adapt.
- Recover gradually, warm caches, and test the recovery.
See tail latency and overload.
When a transfer is slower than the link
- Round-trip time and loss:
ping,mtr. - One stream against several:
iperf3. - Compare the window with the bandwidth-delay product:
ss -ti. - Capture for retransmissions, zero windows and handshake timing.
- Check hosts (interrupts, drops, offloads) and middleboxes (per-flow limits, MTU).
See network performance.
When you design alerts for a service
- Write the SLIs from the user's side, and the SLO as minutes of budget.
- Page on burn rate over a long and a short window; ticket on a slow burn; never page on a cause.
- Check low traffic: how many failures does the budget allow, and does one of them trip a rule?
- Give every page an owner and a runbook, and test the rules with replayed history and injected faults.
- Alert on silence, and keep a heartbeat on the paging path.
See SLOs, error budgets and alerting.
When you design a high-throughput data plane
- Packet rate at the worst frame size, then cycles per packet, then the cost of a cache miss.
- Hash flows to cores symmetrically; keep per-core tables; avoid locks on the fast path.
- First packets on a slow path with admission control; every later packet on a fast path.
- Size and age the session table (timer wheel); decide what happens when it is full.
- Choose the stack (kernel, XDP, polling), count TLS cost separately, choose a failure policy, benchmark inline with features on.
| Question | Short answer | Open |
|---|---|---|
| Latency or throughput? | Latency is time per request; throughput is completed work per second. Batching trades the first for the second | Fundamentals |
| Why p99 and not the average? | Averages hide the tail, and fan-out makes the tail typical. Keep mergeable histograms | Fundamentals |
| What does Little's Law give you? | In flight = rate × latency: it sizes pools and checks benchmarks | Fundamentals |
| Why does latency explode near saturation? | Waiting grows as ρ ÷ (1 − ρ): going from 90% to 95% doubles it, and variability makes it worse | Fundamentals |
| Why does adding cores stop helping? | Contention (a serial part) and coherency (shared writes): the Universal Scalability Law peaks and then falls | Fundamentals |
| CPU is at 55% and p99 climbs. Why? | Another resource is the bottleneck (a lock, a pool, a disk), or per-core skew, bursts or throttling. Compute each ceiling | Fundamentals |
| What is coordinated omission? | A closed-loop generator stops sending during a stall, so the worst moments are never measured. Measure from the intended send time | Load testing |
| Open or closed workload? | Open where clients arrive independently of your speed; closed for fixed pools | Load testing |
| How do you compare two builds? | Per-run values, interleaved runs, a bootstrap interval, a minimum effect and enough runs | Load testing |
| How do you find a bottleneck? | Outside in: where is the time, which resource is full (USE), profile it, predict, change one thing, re-measure | Profiling |
| CPU is low and latency is high. Now what? | The requests are waiting: off-CPU view, thread dumps, pool and lock metrics | Profiling |
| Container p99 spikes at 40% CPU. Why? | CFS quota throttling: busy threads use the quota early and freeze for the rest of the period | Profiling |
| How do you cut tail latency? | Reduce variability, then hedge after about the p95 (about 5% extra load), use probation and partial results | Tail and overload |
| What happens past capacity? | Queues grow, servers do zombie work, retries multiply load, and a metastable failure can outlast its trigger | Tail and overload |
| How do you protect a service from overload? | Bounded queues, deadlines, early shedding by priority, adaptive LIFO or CoDel, retry budgets, client throttling, adaptive limits | Tail and overload |
| A fast link gives a slow transfer. Why? | The window is below the bandwidth-delay product, or loss caps it (Mathis). Check scaling, buffers and middleboxes | Network |
| Why do short requests feel slow? | Round trips: handshakes and slow start dominate. Reuse connections and terminate near users | Network |
| Small messages stall for 40 ms. Why? | Nagle meeting delayed ACK. One write per message, and TCP_NODELAY | Network |
| How do you alert on an SLO? | Burn rate over two windows: page at 14.4 over 1 hour (and 5 minutes) and 6 over 6 hours (and 30 minutes), ticket at 1 over 3 days. A raw error-rate threshold is noisy and blind | SLOs and alerting |
| How much failure does 99.9% allow? | 43.2 minutes in 30 days. A full outage burns at 1,000 times the sustainable rate, so it empties the budget in 43 minutes | SLOs and alerting |
| The metrics bill tripled. Why? | A label with many values (ids, raw URLs) or per-pod churn: series are the product of the label values, and a histogram multiplies them again | Observability |
| How do you sample traces? | Head sampling is cheap and blind. Tail sampling keeps errors and slow requests but buffers whole traces and routes by trace id. Compute metrics before sampling | Observability |
| Design a performance CI platform | Tiers, selection and batching; noise control; change-point detection; bisect; triage with evidence | Platform |
| Design a packet inspection gateway | Cycle budget; per-core share-nothing; symmetric hash; fast and slow paths; timer-wheel session table; bypass; inline benchmark | Gateway |
Restate the goal with a percentile and a load. Model it with one formula and real numbers. Name the resources that could be the limit and the one you expect. Say how you would measure it, what you predict, and what you would change first. Close with what happens at twice the load, and how you would keep the gain.
Five families cover most performance questions. Queueing and capacity (Little's Law, utilization, the hockey stick, USL and Amdahl) tell you what to expect before you measure. Measurement and statistics (open loops, intervals, run counts, change points) tell you what to believe. Profiling and overload control tell you what to do. Network and packet arithmetic (round trips, the bandwidth-delay product, loss, packet and cycle budgets) tell you what the wire and the CPU allow. Reliability arithmetic (error budgets in minutes, burn-rate alerts, series and span volume) tells you what to promise and how to watch it. Practice the worked examples until the numbers come without a calculator.
Try answering out loud before you reveal each answer.
QuestionA service has a 99.9% SLO over 30 days. How much of the budget does a burn rate of 14.4 use in an hour, and how long until the whole budget is gone at that rate?Reveal answer
14.4 × 1 hour ÷ 720 hours = 2% of the budget. The whole budget lasts 30 ÷ 14.4 = 2.1 days, which is why a burn rate of 14.4 pages. A burn rate of 1 would last the full 30 days and only files a ticket.
QuestionA service handles 1,000 requests per second at 120 ms mean latency. How many requests are in flight, and what is the p99 for a single-server queue (M/M/1) at 80% utilization with a 10 ms service time?Reveal answer
In flight: 1,000 × 0.12 = 120. For the queue, the mean response is 10 ÷ (1 − 0.8) = 50 ms, and the p99 is about 4.6 times that, roughly 230 ms.
QuestionOn a 10 Gbps link with 64-byte frames, how many packets a second is line rate, and how many cycles per packet does one 3 GHz core have?Reveal answer
Each frame takes 84 bytes on the wire, so 10,000,000,000 ÷ (84 × 8) = 14.88 million packets a second. One core has 3,000,000,000 ÷ 14,880,952, about 200 cycles per packet, less than a memory miss.
QuestionA 1 Gbps path has a 40 ms round trip. How much data must be in flight to fill it, and what rate does a 64 KB window give?Reveal answer
The bandwidth-delay product is 125,000,000 bytes per second × 0.04 s = 5 MB. A 64 KB window gives 65,535 ÷ 0.04 s = 1.64 MB/s, about 13 Mbps.