Lesson 9 of 9 · 22m
Performance Incident Response and Regression Control
A calm operational playbook for latency incidents — isolate the saturated layer, restore service safely, preserve evidence, and prevent regressions with budgets.
When production is slow, the worst response is random optimization. Restarting PHP because it worked last time, adding cache because caching is generally good, or shipping an index untested can each make the incident worse. Treat performance degradation like any other operational incident: stabilize first, preserve evidence, then understand.
Establish the shape in five minutes
Ask three questions immediately:
- Is all traffic slow, or only some endpoints, users, or regions?
- Are workers busy on CPU or blocked waiting for dependencies?
- What changed: deploy, migration, traffic, feature flag, dependency?
Useful first-pass commands:
top -H
pidstat 1
ss -s
mysql -e 'SHOW PROCESSLIST'
redis-cli --latency-history -i 1Look at nginx request rates, FPM active processes and queue, database slow queries, upstream latency, cache hit ratio, and error distribution. You are trying to identify the saturated constraint, not collect every graph in existence.
Stabilize with reversible moves
Good mitigations are explicit and reversible: reduce traffic to nonessential endpoints, increase queue-consumer capacity, disable an expensive feature flag, temporarily raise a downstream timeout only if deadlock ordering is understood, or roll back a known bad deploy. Dangerous mitigations are vague: restart everything, flush every cache, increase all worker counts.
If the database is saturated, adding PHP workers usually worsens it. If PHP workers are memory-starved and swapping, adding workers accelerates collapse. Scaling the layer before the bottleneck increases pressure on the bottleneck.
Preserve the evidence before it evaporates
Capture representative slow traces, query digests, process snapshots, and deploy identifiers. After recovery, reconstruct the causal chain while the facts still exist:
14:03 deploy 2026-11-30.7 begins
14:06 OPcache resets on all nodes
14:07 catalog object cache hit ratio falls from 94% to 31%
14:08 database query concurrency triples
14:10 FPM active workers saturate; listen queue grows
14:12 nginx starts returning 502That timeline points to cold-cache stampede and deployment coupling, not a sudden need for more servers.
Regression control is a budget, not a wish
Define service-level budgets per critical endpoint: p95 latency, error rate, dependency time, query count, and cache hit ratio. Alert on burn rate and add lightweight release checks for known expensive invariants. Performance tests in CI should catch cliff-edge regressions such as query explosions, not attempt to reproduce all of production.
Field notes
- During an incident, changing three things at once destroys attribution and often multiplies risk.
- A rollback is not automatically safe if schema or cache formats changed; verify compatibility first.
- Warm caches gradually after recovery when possible. The post-incident stampede can create a second outage.
- Write the postmortem around queueing and saturation mechanics, not blame.
Was this lesson helpful?