Benchmark design
Start with a question, not a traffic generator
A benchmark is a controlled measurement of a specified workload. Decide whether you want faster static delivery, lower proxy latency or fewer errors before choosing a tool. A baseline is the result before the change. A useful comparison preserves the same payload, method, protocol, connection policy, concurrency and cache state. A small experiment teaches measurement but does not estimate production capacity. This example plan fixes the target and caps the work; use only the private lab you own.
Question: does gzip reduce transferred bytes for this text fixture?Target: 127.0.0.1:19444 /sample.txtHTTP/1.1; fresh connection each request; concurrency 1Maximum 8 requests per arm; stop on first unexpected responseRead client-side timing
curl reports elapsed times in seconds. time_starttransfer ends at the first response byte, while time_total includes the whole transfer. Neither is simply backend CPU time. In a new direct HTTP connection, time_connect includes time before connection establishment; a reused connection changes the meaning of this comparison. The command forces HTTP/1.1, avoids ambient proxy settings and caps time. Run only after the supplied lab is started. Results vary.
curl -q --noproxy "*" --http1.1 --max-time 3 \ --output /dev/null --silent --show-error \ --write-out "status=%{http_code} first=%{time_starttransfer} total=%{time_total}\n" \ http://127.0.0.1:19444/sample.txtControl warm and cold conditions
A warm filesystem cache or persistent connection can make a later request faster without any configuration improvement. A cold browser cache, cold disk page cache and new TLS connection are different conditions. Never drop host caches to manufacture a cold trial. Use a fixed warmup protocol, discard only predeclared warmup observations and record what you cannot control. This local lab is cleartext HTTP and fresh connections; it says nothing about TLS handshake performance.
Warmup: 2 requests per arm, not included in summaryMeasured: 6 requests per armSame file bytes and Accept-Encoding: gzipFresh TCP connection every requestUncontrolled: OS page cache, CPU schedulingBound the experiment and record context
Tools such as k6 report request counts, failures and durations; wrk, hey and ab have their own definitions and controls. Do not copy duration-only load recipes: fast endpoints can receive many requests before a timer expires. The included Python runner uses a fixed local address, sequential requests, a strict response size bound, an overall process deadline and early exit on errors. For future concurrent trials predefine total requests, maximum in-flight work, duration and resource stop thresholds; stop if CPU, memory, disk or network pressure exceeds your lab budget. Record client and server versions, machine allocation, config hash, payload and sampling rules.
Metadata: OS/architecture, CPU allocation, RAM limitNginx build, client version, config hash, payload hashAbort: unexpected status/body, timeout or operator stopNo external endpoints, no repeated stress runsPractice and recap
Design an experiment comparing static compression with at most 16 total local requests. Specify warmup, client headers, protocol, deadline, resource abort and metadata. Check your reasoning against the manual exercise. Next: Latency and throughput interpretation.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Benchmark design
Define workload, baseline and measurement units
Which variable should stay fixed when testing compression?
What does time_starttransfer include?
What is a warmup?
Which experiment is appropriate here?
Why record connection reuse?