Performance experiment design
Define the outcome before measuring
Throughput is completed work per time; latency is elapsed time for one operation; saturation is pressure on a constrained resource. Measure errors and offered work separately from successful throughput. For 100 attempted requests in 10 seconds, with 95 successes, successful throughput is 9.5 requests/s and error rate is 5%. A higher throughput is not automatically better if latency or errors violate the service objective. Use an explicit workload and acceptance criteria before changing requests or scheduling policy.
Attempts: 100; successes: 95; duration: 10 sSuccessful throughput = 95 / 10 = 9.5 requests/sError rate = 5 / 100 = 5%Measure the tail without hiding failures
p95 is a quantile, not a maximum. For this lesson use nearest-rank on a sorted list of n successful latencies: index ceil(0.95*n), with one-based indexing. With 20 samples where the first 18 equal 10 ms and the last two are 100 and 200 ms, p95 is 100 ms and p99 is 200 ms. Small samples give unstable tail estimates. Report errors and timeouts separately; excluding failures without reporting them biases results. Prometheus histograms estimate quantiles from bucket observations; do not average per-Pod p95 values as a fleet p95.
Sorted samples: 18 × 10 ms, 100 ms, 200 msp95 rank = 19 -> 100 ms; p99 rank = 20 -> 200 msControl one change and record the environment
Compare a baseline and candidate using the same image, dataset, workload, arrival pattern, duration, warm-up, sample count, hardware, runtime and measurement method. Change one factor, for example packing policy or CPU request. Record node types, kernel, Kubernetes version, resource limits, placement and background load. Repeat runs and alternate order when feasible; cache warmth, JIT compilation and noisy neighbors can distort results. A load generator that waits for each response can hide demand during slowdowns, so record offered load and scheduling of requests.
Baseline A: fixed workload + request 1000mCandidate B: identical workload + request 750mRepeat A/B and B/A; compare errors, throughput and tail latencyUse bounded experiments and explicit gates
A production load test needs authorization, isolation, resource ceilings and abort conditions. Start small and stop when error, saturation or latency thresholds are exceeded. The accompanying local micro-experiment compares a linear scan with a prebuilt dictionary lookup on the same small synthetic inventory. It records actual local wall-clock durations, environment, operation counts and sample values. It measures Python lookup work only, not Kubernetes scheduler speed. Dictionary construction is outside the timed interval, so do not claim an end-to-end speedup. Report raw samples rather than relying on one run.
100 records, 200 lookups per sample, 9 samples per variantWarm-up excluded; alternate variant orderNo network, no cluster, no concurrency or stress testPractice and next step
Run validate_offline.py to verify latency and throughput calculations, then run measure_local.py if Python is available. Inspect measurement-evidence.json for the authoring run and compare your own measurements without expecting identical timing. Explain two reasons a Python timing result cannot validate production scheduling. Next: batch, data, AI and specialized workloads.
python validate_offline.pypython measure_local.pyFurther reading
- https://prometheus.io/docs/practices/histograms/ — Histograms, summaries and quantile estimation
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Performance experiment design — knowledge check
Specify reproducible latency and throughput measurement
95 successful requests in ten seconds gives what successful throughput?
What is nearest-rank p95 for 18 samples of 10 ms and two of 100 and 200 ms?
Can per-Pod p95 values be averaged to get a fleet p95?
What is a controlled comparison?
What does the supplied Python micro-experiment establish?