Controlled optimization
Change one setting and test a prediction
Choose an intervention with a falsifiable prediction. For compressible text, enabling gzip can decrease representation bytes sent to clients but increase CPU work. This lab uses two separate configurations that differ in exactly one directive. The fixed payload and request headers stay identical. Compare encoded bytes and decoded body integrity first. Do not claim lower latency or better capacity merely because the response is smaller.
# Both configs: http context, same file and MIME settingsgzip_min_length 256;gzip_vary on;# A: gzip off;# B: gzip on;Read baseline and candidate results
Suppose a fictional workload reports the following results from equal request counts and equivalent conditions. The candidate reduces wire representation size but increases p95 latency and introduces one error. A latency-sensitive objective with a zero-error requirement rejects this candidate. This is a decision example, not measured Nginx output. For the tiny supplied lab, byte counts and functional correctness are the primary observations.
Synthetic only baseline candidatevalid responses 100/100 99/100p95 duration 20 ms 28 msencoded body bytes 16384 1024Decision: reject; investigate error and latencySeparate causation from coincidence
Repeat comparable trials under approved limits; a single A then B run is vulnerable to order effects. An A/B/A sequence can reveal drift, but needs a separate reviewed request budget. A fixed-concurrency closed-loop client may issue less work during a slowdown, masking queued demand; report workload model. Real capacity experiments need controlled arrival rates, longer representative observations and independent resource monitoring. Do not extrapolate this micro-lab to customers or publish it as a benchmark.
A1 baseline → B candidate → A2 baselineIf A1 and A2 disagree substantially, investigate drift.Record warmup, sample count, failed requests and variance.Prepare rollback before tuning
Keep the known-good configuration, verify changes using the private prefix and record a rollback trigger. For this lab, stop A cleanly before starting B; do not compare two competing instances. In production, a reviewed rollout, canary and monitoring are necessary; the lab is not a production deployment procedure. If any response differs after decoding, stop, revert and diagnose. The command below checks syntax only; it does not prove runtime improvement.
nginx -t -p "$PWD/" -c candidate.conf# If validation fails: do not activate the candidate.# Retain baseline.conf for the next approved run.Practice and recap
Candidate saves 70% representation bytes, has one incorrect body and shows higher p95. State a decision and rollback plan for a zero-error objective. Check your reasoning against the manual exercise. Next: Structured request logging.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Controlled optimization
Change one setting and compare evidence
What does gzip primarily change in this trial?
Why check the decoded body?
Candidate is smaller but has an error under a zero-error objective. What next?
What can an A/B/A comparison reveal?
What does nginx -t establish?