Performance Troubleshooting & Incident Response Questions
Diagnosing and resolving performance problems in production, often under time pressure. Covers latency and slowdown investigation, reproducing and narrowing performance regressions, reading live diagnostic evidence (logs, thread dumps, resource and network captures), runbooks and automated remediation for recurring incidents, restoring healthy behavior while preserving reliability, and communicating status and escalation decisions mid-incident. Emphasizes systematic debugging of live systems over offline experimentation.
You observe that a service's p99 latency has increased from 200ms to 1200ms over the last hour. Describe a structured troubleshooting workflow (step-by-step) you would follow to identify and mitigate the root cause. Include quick mitigations and what you'd capture for a later post-incident review.
Sample Answer
Direct answer: Treat this as a live incident, not a puzzle to solve calmly. In the first minutes, establish scope and correlate the timing against recent changes (deploy, config, traffic), decide on a fast reversible mitigation, and run deeper diagnosis in parallel rather than waiting for a full root cause before acting.
Structured elaboration:
- Minute 0 to 5, confirm and scope. p99 (the 99th percentile latency: 99% of requests are faster than this number) rising while p50 (the median latency: half of all requests are faster than this) stays flat means a growing minority of requests are getting badly hit, not a uniform slowdown. Check if this is one endpoint, one host, one region, or everything, and check the error rate alongside latency, not latency alone.
- Minute 5 to 10, correlate with change. Pull the deploy log, config/feature-flag change log, and traffic graph for the last one to two hours. A step change in p99 that starts exactly at a deploy or config push is your strongest early signal.
- Minute 10 to 20, decide on mitigation. If a change correlates, roll it back, since rollback is usually fast and reversible. If nothing correlates but a resource looks saturated (CPU, DB connections, thread pool queue), scale up or shed load. If a downstream dependency is clearly the cause, trip a circuit breaker (automatically stop sending requests to that dependency for a cooldown period once its failure rate crosses a threshold, so it can recover instead of being hit harder) or fail over.
- In parallel, preserve evidence. Pull traces for the slowest requests before you touch anything that would erase them (an instance getting killed or scaled down loses its state).
- Set an explicit rollback threshold before you decide, not during. For example: "if p99 hasn't dropped within 5 minutes of the rollback completing, or the error rate is still climbing, treat this candidate as ruled out and move to the next hypothesis." Writing this down ahead of time stops the team from waiting indefinitely on a fix that isn't working.
Worked example: Service-wide p99 climbs from 200ms to 1200ms starting 55 minutes ago. The deploy log shows a release went out 58 minutes ago. Splitting the latency metric by version, the 95% of traffic still on the old build has p50 around 45ms and p99 around 210ms, while the 5% already on the new build has p50 around 700ms, p80 around 1200ms and p99 around 3000ms. Sanity-check that the two halves can actually produce the number on the dashboard before you act on them, because a mixture's p99 can never be worse than the worst of its parts: if the canary's own p99 were 1150ms, no mix of it with a 210ms version could ever show a service-wide p99 of 1200ms, and a pair of numbers like that means one of the two metrics is mislabelled or scoped wrong. Here the arithmetic works out: the aggregate p99 is the point where 1% of all requests are slower, the canary supplies 5% of traffic, and 0.05 x 0.20 = 0.01, so the service-wide p99 lands where the canary's slowest fifth begins, which is the canary's p80 of about 1200ms. Everything else is held constant (same infrastructure, same traffic mix, only the version differs), so that is a clean causal signal and you roll the deploy back immediately rather than spending the next 20 minutes profiling. The same arithmetic is worth running in reverse before a rollout: a 5% canary that is merely twice as slow as the old build barely moves the service-wide p99 at all, which is why you alert on canary-versus-baseline percentiles rather than waiting for the aggregate number to move.
Trade-offs and pitfalls: Rolling back the first thing that correlates without checking whether it's plausible wastes the recovery window if you're wrong. Restarting or scaling an unhealthy instance before pulling traces or a profile from it throws away the evidence you need for the post-incident review. For that review, capture the exact timeline (when it started, when you noticed, when you mitigated), the before and after metrics, the change you rolled back or the resource you scaled, and, once found, the actual root cause, packaged as a short runbook (a step-by-step reference for handling this specific type of incident) so the next person facing the same symptom has a checklist instead of starting from zero.
A customer-facing API's read latency keeps increasing as the underlying database grows, even though the right indexes exist. Lay out a systematic approach to determine whether the cause is index inefficiency, full table scans, cache eviction, or storage throughput, and describe what evidence you would gather at each layer to confirm which one it actually is.
Sample Answer
Direct answer: Having "the right indexes" only guarantees the query planner picks a good access path, not that reading through that index stays cheap as data grows. The actual cause is one of index bloat, the planner drifting away from the index, the working set no longer fitting in cache, or a physical storage throughput ceiling, and each has its own distinct evidence.
Structured elaboration, evidence at each layer:
- Index inefficiency or bloat: many databases (Postgres, for example) accumulate dead space in a b-tree index if maintenance (vacuum) can't keep up, growing the index's physical size and lookup cost disproportionately to row count. Check the index's actual size over time against row-count growth.
- Full table scans: run
EXPLAIN ANALYZE(a command that shows the actual query plan the database chose, along with real measured row counts and timing for each step, not just an estimate) on the slow query. If it shows a sequential scan instead of the expected index scan, check whether table statistics are stale, since a planner working from outdated row-count or selectivity estimates can silently switch away from the index it used to pick. - Cache eviction: check the database's buffer cache hit ratio (the fraction of reads served from memory rather than disk) over time with the same query pattern. A declining hit ratio as the table grows, with nothing else changing, means the working set no longer fits in the cache it used to fit in.
- Storage throughput: check IOPS (I/O operations per second) and throughput utilization plus latency at the storage-volume level. If utilization is pinned near the provisioned ceiling as data grows, that's a physical limit, unrelated to the query plan at all.
Worked example: A table grows from 5 million to 50 million rows over six months. The buffer cache hit ratio drops from 98% to 82% over the same period, with the query's WHERE-clause pattern unchanged. EXPLAIN ANALYZE still shows an index scan being used, ruling out a planner regression to a full scan, but its Buffers output (which reports actual hit versus read counts for that execution) shows a much higher proportion of disk reads relative to cache hits than before. Index size has grown roughly in line with row count, not disproportionately, ruling out bloat. Storage IOPS utilization sits around 40% of provisioned capacity, well below its ceiling. The conclusion: cache eviction is the actual cause, the working set no longer fits in the buffer cache as the table grew, forcing more physical reads per query even though the index itself is correctly chosen and structurally healthy. The fix is increasing the buffer cache size, partitioning or archiving old, rarely queried rows out of the hot table to shrink the effective working set, or adding a dedicated caching layer in front of the hottest lookups.
Trade-offs and pitfalls: assuming "the index exists, so it must be fast" ignores that even a correctly used index still costs a real disk read if its relevant pages aren't cached. Rebuilding indexes as a reflexive bloat fix, when the real cause is cache eviction, wastes a maintenance window for no benefit. Seeing acceptable IOPS utilization doesn't rule out storage as a problem either, since a device can have headroom on throughput but still show elevated per-request latency under a bursty access pattern, so check latency, not just utilization.
Tell me about a time you handled a performance incident in production. Use the STAR format: Situation, Task, Action, Result. Focus on how you diagnosed the problem, what short-term mitigation you implemented, and what long-term changes you pushed afterwards.
Sample Answer
Direct answer: A strong answer to this question shows three things in sequence: how you triaged and made a decision before you had a confirmed root cause, what you shipped as a reversible stop-gap versus what you shipped as the durable fix, and what changed on the team afterward so the same failure mode doesn't come back. "I fixed it and it worked" tells the interviewer nothing.
Situation and Task: I was the on-call backend engineer for a checkout service. About twenty minutes after a routine deploy, our p95 latency (the 95th percentile response time: 95% of requests come in faster than this number, so it captures the slow tail an average would hide) jumped from around 300ms to over two seconds, and the 5xx error rate started climbing as some requests began timing out. My job in the first few minutes wasn't to find the root cause, it was to stop the customer-facing bleeding and figure out fast whether the deploy was even the cause.
Action and Result: I pulled the deploy timeline next to the latency graph and split the latency metric by build version. It was a rolling rollout, so twenty minutes in most instances were already serving the new build while a handful had not been updated yet: the new-build instances showed the spike and the not-yet-updated ones sat at their normal 300ms. That split is what let me act on twenty minutes of data instead of waiting for a root cause, and it is also why the version label on the latency metric matters more than it looks: without it the graph is one line that went up and every hypothesis stays alive. Rather than wait for a full root cause, I rolled the deploy back right away since it was low-risk and reversible, and asked a teammate to pull a thread dump and a slice of traces from one struggling instance before it was torn down, so we wouldn't lose the evidence. Latency recovered within a few minutes of the rollback finishing. Working from the preserved traces afterward, we found that the new deploy had added a synchronous call to a rarely used fraud-check service with no timeout set, so a handful of slow fraud-check responses were tying up request threads and building a backlog. Longer term, we added an explicit timeout and circuit breaker (a safeguard that stops sending requests to a dependency once its failure rate crosses a threshold, so it gets a cooldown to recover instead of being hit while already failing) around that call, added a load test that specifically exercises dependency slowness before merge, put a real canary stage in front of this service's rollouts (a deliberately small first slice of traffic on the new build, watched against the old build's percentiles before the rollout proceeds, so a regression like this one is caught at a few percent of exposure instead of after it has reached almost every instance), and turned the incident writeup into the template our team now uses for "mitigate first, diagnose second" decisions.
Trade-offs and pitfalls: A weaker version of this story stops at "I rolled it back and it got better," with no explanation of why the rollback was the right call at that moment or what evidence justified it. It's also a mistake to only tell the mitigation half of the story: an interviewer specifically wants to hear the long-term change, because a stop-gap that never gets followed up on is the same incident waiting to happen again.
After a deploy, your service's p95 latency jumps 40% and holds there. Walk through how you would investigate: what telemetry and traces you would check first, what experiments you would run (including load tests and fault injection) to narrow the cause down to CPU, GC, network, or a downstream dependency, and how you would decide between rolling back the deploy and shipping a targeted fix.
Sample Answer
Direct answer: When p95 latency (the 95th percentile response time) jumps and then holds flat right after a deploy, the fastest lever is usually rollback, since it's reversible in minutes, while you diagnose in parallel. Don't let the search for root cause block the mitigation decision.
Structured elaboration:
- Telemetry first: compare the new deploy's dashboards against the prior version for CPU utilization, garbage collection (GC: a managed runtime periodically pausing to reclaim memory it no longer needs) pause frequency and duration, downstream dependency latency from traces, and network-level retry or error counts, ideally split by version if canary tagging exists.
- Trace comparison: pull a handful of the slowest request traces from before and after the deploy and look at the span waterfall. Is the extra time inside your own service's code, in a lock, or waiting on a downstream call?
- Experiments: fault-inject added latency into one candidate downstream dependency in staging and measure how many milliseconds of p95 you get per millisecond you inject. Be precise about what that buys you, because it is easy to overclaim: reproducing a p95 shift proves only that the call sits on the request's critical path and gives you a sensitivity coefficient. It does not show that this dependency is what changed in production, which is the actual hypothesis. The causal argument needs both halves multiplied together: the sensitivity from the injection, and the dependency's own measured latency delta in production across the deploy boundary, with the product accounting for most of the observed p95 move. If the dependency's latency did not move in production, a clean injection result is irrelevant no matter how well it reproduces, and if it did move but only by 5ms against a 120ms p95 jump, it is a contributor and not the cause. Separately, load-test the new version alone, without any real downstream dependencies in the loop, at matching request volume, to see if the code path itself (CPU or GC) explains the jump on its own.
- Categorize the eventual fix along four axes: code (an inefficient new code path, such as added serialization or computation), resources (an undersized CPU, memory, or thread-pool allocation for the new code path), network (a chattier call pattern with more round trips), or configuration (a changed timeout, connection-pool size, or feature-flag default).
- Rollback versus fix forward: default to rollback in the first response window since it's low-risk and reversible. Fix forward only when the regression traces to a single config value you can flip immediately (a feature flag), or when rollback itself carries real risk, for example if the deploy also included a data migration that isn't safely reversible.
Worked example: The deploy goes out at 10:00. p95 jumps from 300ms to 420ms (a 40% increase) immediately afterward and holds flat for the next hour rather than climbing further, which rules out a slow leak and points to a discrete step change caused by the deploy itself. Trace comparison shows CPU time spent inside your own process rose from about 40ms to about 150ms per request, with no material change in downstream call latency, and GC pause telemetry is unchanged. That combination points to code, not GC and not network. You fault-inject 100ms of extra latency into that downstream dependency in staging and staging's p95 moves by roughly the same 100ms, which establishes sensitivity of about 1ms of p95 per 1ms of dependency latency and nothing more. The production traces show that dependency's own latency unchanged across the deploy boundary, so there is no delta for that sensitivity to act on: 1.0 times roughly zero explains none of the 120ms. "The dependency coincidentally got slower" is ruled out by the production measurement, not by the injection, and the injection's real value here was proving the traces were not simply missing the call. With no config change involved and the regression clearly inside application code, you roll back rather than trying to patch the code path live under pressure.
Trade-offs and pitfalls: rollback isn't free either. If the deploy included a schema or data change, rolling back the code without also reversing the data change can leave the system in an inconsistent state, so check reversibility before defaulting to it. Chasing GC or network hypotheses before ruling them out with the telemetry you already have wastes time exactly when time is scarce, and trusting a single slow-trace sample without a second one to confirm the pattern risks over-fitting to noise.
A web service at normal request volume suddenly shows a spike in 5xx errors and increased latency, even though CPU and memory look normal. Outline a structured troubleshooting plan for the first 30 minutes: what logs, external dependency checks, and runtime-state inspections you would perform to find the root cause.
Sample Answer
Direct answer: Since CPU and memory look normal, the problem is probably not resource saturation on your own host; it's more likely a downstream dependency slowing down, threads piling up waiting on something (which costs almost no CPU while blocked), or a specific change like a config or certificate issue. The first 30 minutes should check exactly those things in order, starting with logs and ending with runtime state.
Structured elaboration:
- 0 to 5 minutes, logs. Look for a common error or exception pattern behind the 5xx spike, and check whether it's concentrated on one endpoint or spread across all of them.
- 5 to 10 minutes, external dependency checks. Look at latency and error-rate dashboards for downstream APIs and the database directly, not just your own service's view of them. Check connection-pool metrics (checked-out connections, wait-queue depth); requests piling up waiting for a pool resource explains rising latency and errors while CPU stays flat, since blocked threads aren't burning CPU cycles.
- 10 to 20 minutes, runtime-state inspection. Take a thread dump (a snapshot of what every thread is currently doing). If a large fraction of threads are BLOCKED or WAITING at the same call site, that's the smoking gun, thread-pool exhaustion behind a slow or hung downstream call, and it explains the symptom without CPU ever needing to be elevated.
- 20 to 30 minutes, recent changes. Check deploys, config pushes, dependency version bumps, and expiring certificates or credentials around the exact start time of the spike; a routine certificate rotation is a classic cause of "everything was fine and then suddenly errors."
- Mitigation once you have a lead: if a downstream dependency is degraded, add a tight timeout and circuit breaker (a safeguard that stops sending requests to a struggling dependency once failures cross a threshold, so it gets a chance to recover instead of being hit further) so requests fail fast instead of holding a thread indefinitely; if the pool itself is undersized for this failure mode, temporarily raise its size or shed load; if it's a deploy, config, or certificate issue, roll back or fix the specific item directly.
Worked example: A thread dump shows 180 of 200 available worker threads BLOCKED in the same stack frame, waiting on a socket read to a payments service. That payments service's own latency dashboard shows its p99 (the 99th percentile latency: the slowest 1% of requests) climbed from 100ms to about 8 seconds starting at the same minute the 5xx spike began, before its own team's alerting had fired. CPU and memory looked normal because those 180 threads are idle-blocked, not computing, they're simply occupying slots so new requests can't get a thread and start timing out or erroring, which explains both symptoms (high error rate and flat CPU) at once. The immediate mitigation is a tight timeout, around 500ms, plus a circuit breaker on calls to the payments service, so blocked threads free up quickly and new requests fail fast with a clear error instead of exhausting the pool, while paging the payments-service team in parallel.
Trade-offs and pitfalls: spending the first 20 minutes staring at CPU and memory dashboards "because that's what we always check first" wastes exactly the window where a thread dump would have given the answer immediately. A fail-fast circuit breaker converts "slow and eventually erroring" into "fast and erroring immediately" for affected requests, which is better for pool health but is still a real user-facing error, so it should be communicated as a mitigation, not framed as a fix.
Unlock Full Question Bank
Get access to all 33 Performance Troubleshooting & Incident Response interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.