Investigating and Mitigating Production Latency Spikes
System DesignModel answerLast updated
Walk through triaging a production alert for elevated service latency, from confirming impact to investigating root causes and restoring service.
You receive an alert at 3 AM indicating elevated latency across one of your production services. Users are experiencing slow page loads and timeouts.
Walk through your approach to triaging, investigating, and resolving this incident.
Your response should address:
- How you validate the alert and determine severity
- Methods for identifying which users, endpoints, or components are affected
- Diagnostic techniques at the infrastructure, network, application, and dependency layers
- Immediate actions you would take to restore service quality
- How you coordinate and communicate throughout the incident
Think through this as a real-world scenario where speed matters but so does avoiding collateral damage from hasty changes.
Hints
Hint 1
Start by validating the alert is genuine and determining whether the issue affects all traffic or specific slices (region, endpoint, customer tier).
Hint 2
Consider what changed recently—deploys, config updates, traffic patterns, or dependency incidents are the most common triggers.
Hint 3
Mitigation comes before diagnosis: if evidence points to a recent change, rolling back is often faster and safer than deep investigation.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Model Answer: Production Latency Incident Response
Core Philosophy
The fundamental principle is restore first, understand later. Your goal is to stop customer pain as quickly as possible, then investigate the root cause once service is stable. Every action should be deliberate, reversible where possible, and documented with timestamps.
Two mental frameworks guide the investigation:
- RED metrics for services: Rate, Error rate, Duration
- USE method for resources: Utilization, Saturation, Errors
Phase 1: Validate and Scope (First 3–5 Minutes)
Confirm the signal is real. Alerts can trigger due to monitoring gaps, configuration drift, or scraping failures. Check the underlying dashboard:
- Is p99 latency actually elevated, or is this a single flapping metric?
- Cross-validate with an independent data source: synthetic monitors, load balancer metrics, or a manual test from your laptop
Run a quick black-box check:
curl -w "connect: %{time_connect}s, TTFB: %{time_starttransfer}s, total: %{time_total}s\n" \
-o /dev/null -s https://api.example.com/health
Assess severity. Compare current performance against your SLO:
- If your p99 SLO is 500ms and you're seeing 3s, that's severe
- Is the error rate climbing alongside latency? Timeouts compound the problem
- What's the trend—flat, improving, or accelerating?
Declare an incident severity (SEV-1, SEV-2, etc.) based on user impact and error budget burn rate, not just how alarming the graph looks. This determines response urgency and escalation.
Phase 2: Identify Blast Radius and Impact
Slice metrics by every available dimension to distinguish "everything is broken" from "one thing is broken":
| Dimension | What it reveals |
|---|---|
| Endpoint/route | Specific code path regression |
| Geographic region or availability zone | Infrastructure or network issue |
| Host/pod identifier | Bad node, resource exhaustion |
| Deployment version/canary | Recent code change |
| Customer/tenant | Hot partition, abusive client |
| Upstream caller | Dependency cascading failures |
Quantify the impact:
- What percentage of requests exceed the SLO?
- How many active users are affected?
- Are critical paths like authentication, checkout, or API ingestion involved?
Look for recent changes. The majority of production incidents trace back to something that changed:
- Code deploys in the last hour
- Configuration or feature flag changes
- Infrastructure modifications (autoscaling, instance types)
- Traffic spikes from marketing campaigns or viral content
- Dependency service incidents
Check your deployment timeline, audit logs, and dependency status pages.
Phase 3: Systematic Investigation
Work from the outside in, eliminating layers quickly.
Infrastructure Layer
Start with the classic "first 60 seconds" on the suspect hosts:
uptime # load average relative to core count
dmesg -T | tail # kernel errors, OOM kills, disk failures
vmstat 1 5 # CPU (us/sy/wa/st), memory (si/so), I/O (bi/bo)
mpstat -P ALL 1 # per-CPU utilization, spot single-core bottlenecks
iostat -xz 1 5 # disk latency (await), saturation (%util)
free -m # memory pressure, swap usage
df -h && df -i # disk space and inode exhaustion
Key red flags:
- CPU steal time above 10% indicates virtualization contention
- High iowait suggests disk saturation or slow storage
- Swap activity means memory pressure is causing thrashing
- Load average significantly higher than CPU count indicates runnable tasks are queuing
- File descriptor exhaustion: compare
lsof | wc -lagainstulimit -n
For containerized workloads, check CPU throttling: examine nr_throttled in cgroup metrics. Containers can be CPU-starved even when the host looks idle.
Network Layer
ss -s # connection counts and states
ss -tan state time-wait | wc -l # TIME_WAIT accumulation
netstat -s | grep -i retrans # TCP retransmission rate
mtr api.dependency.com # trace route latency and loss
dig @8.8.8.8 api.example.com # DNS resolution time
Check for:
- Connection pool exhaustion or ephemeral port depletion
- Packet loss or retransmits indicating network congestion
- Slow DNS resolution—often an invisible bottleneck
- Load balancer issues: uneven distribution, unhealthy backends, or queue depth
TLS handshake overhead can also spike under load. Look at connection establishment time separately from request time.
Application Layer
Examine service-level metrics and runtime behavior:
- Latency breakdown by endpoint: use distributed tracing to identify which spans expanded (database queries, external API calls, internal processing)
- Thread pool or worker saturation: requests queuing for available workers appear as latency, not CPU load
- Connection pool exhaustion: every request waits for a database connection even though the app isn't busy
- Garbage collection pauses: JVM GC logs, Go GC traces, or language-specific profilers reveal stop-the-world pauses
- Lock contention: thread dumps (
jstack,pprof,py-spy) show threads blocked on mutexes - Retry amplification: clients retrying slow requests can multiply load 10× and create a feedback loop
Generate an on-CPU flame graph or run perf top to see where cycles are going:
perf record -F 99 -a -g -- sleep 30
perf script | stackcollapse-perf.pl | flamegraph.pl > out.svg
Dependency Layer
Latency often originates downstream:
Databases:
- Query performance: slow query logs,
pg_stat_activity(Postgres),SHOW PROCESSLIST(MySQL) - Lock contention or blocking queries
- Connection count at maximum
- Replication lag forcing reads to stale replicas
- Missing index after a schema migration
Caches:
- Hit rate drop after a restart or eviction storm
- Hot key concentration overwhelming a single shard
- Cold cache forcing every request to hit the database
External services:
- Check their status pages and your outbound request metrics
- Tighten timeouts to fail fast rather than queuing
Message queues:
- Consumer lag and backlog growth indicate downstream can't keep up
Phase 4: Immediate Mitigation
Choose the fastest, safest action with the highest likelihood of impact. Prioritize reversible changes.
If a recent change is implicated:
- Roll back the deployment
- Revert the configuration change
- Disable the feature flag
This is the single highest-value action. Don't spend 30 minutes profiling if a deploy went out 10 minutes before the latency spike.
If a specific host or zone is failing:
- Drain traffic from the bad node
- Remove it from the load balancer
- Shift traffic to healthy availability zones
If the system is overloaded:
- Rate-limit or shed non-critical traffic (analytics, recommendations)
- Block abusive clients
- Scale out horizontally if downstream dependencies can handle the load
- Serve cached or degraded responses
If a dependency is slow:
- Reduce timeouts to fail fast
- Enable circuit breakers
- Cap retry attempts with exponential backoff
- Fail over to a replica or alternate provider
If a resource is leaking:
- Rolling restart buys time; capture diagnostics (heap dump, thread dump) before restarting
After each mitigation, observe the metrics for 2–3 minutes to confirm the effect before proceeding. Change one variable at a time when possible.
Phase 5: Coordination and Communication
Incident roles (for SEV-1/SEV-2):
- Incident Commander: coordinates, makes decisions, does not perform technical work
- Operations Lead: executes commands, investigates
- Communications Lead: updates stakeholders and status page
- Scribe: documents timeline and actions
Communication cadence:
- Internal updates every 15–30 minutes in a dedicated incident channel
- External status page updates as appropriate
- Each update includes: current impact, hypothesis, actions taken, next steps, and next update time
Recovery criteria:
- Latency and error rate within SLO for a sustained period (e.g., 10 minutes)
- No ongoing degradation
- Temporary mitigations documented for later cleanup
Post-incident:
- Conduct a blameless postmortem within 48 hours
- Identify action items to prevent recurrence
- Update runbooks with lessons learned
Common Pitfalls
- Premature root-cause analysis: spending 20 minutes investigating when a simple rollback would have restored service
- Changing multiple things simultaneously: impossible to know what worked
- Scaling up blindly: adding capacity when the bottleneck is a database connection pool just shifts the problem
- Ignoring cache cold-start: restarting every instance simultaneously empties all caches and crushes the database
The best incident responders are methodical, communicate clearly, and always prioritize recovery over curiosity.