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.
A long-running Linux service's memory keeps climbing and you cannot restart it right now without dropping in-flight work or losing a warm cache. What would you check to confirm whether this is a genuine leak, and what would you do in the meantime to keep the service running safely while you investigate?
Sample Answer
Direct answer: Rising memory doesn't automatically mean a leak; it could be a cache warming up and plateauing, heap fragmentation, or a genuine leak where objects are retained past when they should be freed. Confirm which one it is by comparing object growth to traffic rather than watching total memory alone, and keep the service alive in the meantime without a full restart by draining and restarting instances one at a time if you're running more than one, or capping the specific growing structure if you're not.
Structured elaboration:
- Distinguish leak from legitimate growth: does memory keep climbing even during a low-traffic window (points to a leak, for example a background timer or job), or does it track request volume and then plateau (points to cache warm-up, not a leak, though the cache may still need a size cap)?
- Get object-level evidence without a blocking pause: prefer a live sampling profiler (RSS: resident set size, the actual physical memory a process is using, isn't precise enough on its own) over a full blocking heap dump. A full heap dump on a large, already-struggling heap can itself cause a multi-second pause, which risks dropping the in-flight work you're trying to protect. Take two snapshots several minutes apart under similar load and diff object counts by type: an object type that keeps growing well past what live request volume could ever require is the smoking gun for a leak.
- Keep it running safely without a full restart:
- Set an alerting threshold well below the OOM (out-of-memory kill) point so you have runway before the process is killed for you.
- If a specific structure is identified as the source and there's an admin endpoint or feature flag to bound or clear it, use that instead of restarting the whole process.
- If the service runs multiple replicas, do a rolling restart, one instance at a time with connections drained first, rather than an all-at-once restart; that avoids dropping in-flight work or losing the warm cache for all traffic simultaneously, at the cost of a cold cache on just the one instance being cycled.
- If it's a single instance with no way to drain traffic, the safest interim step is capping or disabling the specific growing structure through configuration while you keep collecting evidence, and plan a maintenance-window restart once you actually understand the cause.
Worked example: RSS grows from 1.2GB to 4.8GB over six hours while request volume stays roughly flat, so there is about 3.6GB of growth to account for. Two heap histograms taken 30 minutes apart under similar load show one object type, call it PendingRequestContext, growing from about 350,000 to about 383,000 instances, while the legitimate warm-cache object type stays flat around 50,000 entries. Now do the cross-check rather than stopping at "that number went up", because a growing object count on its own is a suspect, not a conviction: 33,000 new contexts in 30 minutes is about 1,100 a minute, which across the six hours of observed RSS growth comes to roughly 400,000 contexts, and 3.6GB spread over 400,000 objects is about 9KB retained each, the right order of magnitude for a request context holding a buffer and a parsed body. The rate, the standing count, and the RSS growth all agree, and that agreement is what turns this into a confirmed diagnosis. Had they disagreed, for example if the accumulated count could only account for a tenth of the 3.6GB, the honest conclusion would be that this object type is real but is not the whole story and a second source of growth is still unexplained. Live concurrency could never require 400,000 pending contexts at once, so something is holding references to completed requests. With the service running three replicas behind a load balancer, the team sets an alert threshold below the historical OOM point and performs a rolling restart, one instance at a time with connections drained, while continuing to collect heap snapshots on the not-yet-restarted replicas to pin down the exact reference leak, which means following the retained-reference chain from a sample of those contexts back to a garbage-collection root rather than just re-confirming the count, since the count already told you everything it can.
Trade-offs and pitfalls: taking a full blocking heap dump on a memory-pressured process can itself cause the pause you're trying to avoid, so lead with a sampling profiler. Jumping to "it's a leak" without comparing growth against traffic wastes investigation time on what might just be a cache that needs a size cap, not a bug. A rolling restart is a real, if partial, restart, and it's worth being honest that it's a mitigation with a real cost (a cold cache on the cycled instance), not a way around the constraint entirely.
Describe how you would track down a performance regression introduced by a code change. Explain how you'd use CI artifacts, benchmark suites, canary deployments, and git bisection to identify the offending change, and how you'd ensure your fix is validated before full rollout.
Sample Answer
Treat this as a search problem across two axes: time (which commit introduced the regression) and evidence (which specific benchmark run proves it), rather than reading through commit history by eye.
CI artifacts: every CI (continuous integration) run should already store its build's performance-relevant artifacts, benchmark output, binary size, profiling data, tagged with the commit SHA. That gives you historical performance data attached to every commit without having to reproduce it after the fact.
Benchmark suites: run the same standardized workload, not ad hoc timing, across the suspect commit range. Look at which specific benchmark regressed and by how much, since that narrows which subsystem actually changed behavior.
Git bisection: use git bisect to binary-search between a known-good and a known-bad commit, running the benchmark suite (or a fast subset of it) at each step and marking it good or bad based on whether the regression reproduces. This finds the exact offending commit in roughly log2(n) steps instead of reading every commit in the range by hand.
Canary deployments: once a suspect fix or revert is ready, roll it to a small percentage of production traffic first and compare its live metrics, specifically the same percentile that regressed (for example p95 or p99, the response time only the slowest 5% or 1% of requests exceed), against a control group still running the previous version. Production traffic patterns can differ from synthetic benchmarks, so this catches anything the benchmark suite missed.
Validation before full rollout: only promote past canary once its metrics match the control baseline over a long enough window to cover normal traffic variation, ideally at least one full peak cycle, and keep an automatic rollback trigger tied to that same percentile in case it regresses again at higher traffic than the canary saw.
Worked example: a nightly benchmark suite shows p95 latency (95th percentile) in the "search" benchmark jump from 45ms to 60ms between two nightly CI runs spanning 30 commits. Running git bisect using that benchmark as the pass/fail check narrows it to a single commit that changed a JSON serialization library's default from compact output to pretty-printing. Reverting just that one setting, not the whole commit, and re-running the benchmark confirms the fix locally. A canary at 5% of production traffic shows p95 back at 46ms against a 61ms control group inside the first hour. That is enough to confirm the fix moves the metric in the right direction, and not enough to promote on: one hour of whatever traffic happens to be flowing does not cover the peak cycle the validation gate above asks for, and a serialization-cost regression scales with payload volume, so the peak is exactly where it would be worst. The canary therefore holds at 5% through the next daily peak with the automatic rollback trigger armed on p95, and only then expands in steps, 5% to 25% to 100%, re-running the same control comparison at each step rather than treating the first green reading as the decision.
Trade-offs and pitfalls: bisection assumes a single clean step-change from one commit, which fails on regressions that build up gradually across many small commits, each individually below your detection threshold; in that case you need to look at the trend line rather than a single good/bad boundary. Also, a benchmark suite with high run-to-run variance produces false bisection verdicts, so confirm the benchmark itself is stable (repeat runs, a real statistical margin) before trusting its automated good/bad calls.
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.
A production service shows increasing CPU steal time on VMs in a cloud provider. Explain what CPU steal means, why it matters for latency-sensitive services, and three remediation options (short-term and long-term) you would evaluate.
Sample Answer
CPU steal time is the percentage of time a virtual CPU wanted to run but the physical host's hypervisor gave that CPU cycle to a different tenant's virtual machine instead, meaning your workload was ready to go but simply wasn't scheduled. It matters for latency-sensitive services because steal time produces unpredictable latency spikes that don't correlate with anything in your own application's metrics: from inside the VM, your own CPU utilization can look completely healthy while you're still being starved, since idle time and steal time are reported as separate things.
Why it especially hurts latency: a request that would normally take 5ms of actual compute can take far longer in wall-clock time if the VM's vCPU (virtual CPU) is repeatedly paused mid-execution while a neighboring tenant runs on the same physical core. The raw accounting does expose this: the Linux kernel tracks steal as its own field in /proc/stat, separate from idle, and top's CPU line, vmstat and iostat all print it as a distinct st or %steal column sitting right next to id or %idle. What makes it easy to overlook is one layer above the raw accounting: the number most dashboards, alerts and autoscalers graph as "CPU utilization" is user plus system time, and that stays low and reassuring precisely because the stolen cycles were never yours to spend. So the signal is present in the per-host tools and absent from the summary view almost everyone actually looks at, which is why exporting the steal field explicitly is part of the fix rather than an afterthought.
Three remediation options
- Short-term: move the workload to different physical hardware. Stopping and restarting the instance (on most cloud providers this reschedules it to a different host) often relieves a noisy-neighbor situation immediately, or scale up to a larger instance size, since larger instance types are typically given more predictable, less-shared CPU allocation.
- Short-term: reduce the application's sensitivity to jitter, for example by adding a small amount of timeout headroom, or spreading load across more, smaller instances so a single steal event on one instance doesn't dominate the aggregate tail latency.
- Long-term: move latency-sensitive workloads to dedicated or reserved instance types with guaranteed, non-shared CPU allocation, or to bare-metal instances where the provider offers them, which structurally removes the possibility of steal since there's no other tenant sharing the core. Alternatively, choose a provider, region, or instance family with a track record of lower oversubscription for this workload class.
Worked example: a service's own CPU utilization graph shows a comfortable 40% average, yet p99 latency (99th percentile) intermittently spikes to 5 times baseline. Checking vmstat 1 with the steal (st) column visible shows steal time jumping to 15 to 20% during exactly those windows, meaning the hypervisor is preempting this VM's vCPUs for another tenant somewhere between a sixth and a fifth of the time during the spike. Note how the two numbers fit together: 40% utilization plus 15 to 20% steal says the VM is being denied a chunk of CPU comparable to half of what it is actually managing to use, which is more than enough to move a tail even though the utilization graph looks relaxed. Migrating to a larger instance size in the same family, which the provider allocates more predictably, drops steal time to under 1%, and the p99 spikes disappear over the following 24 hours of observation.
Trade-offs and pitfalls: a bigger instance or dedicated hardware costs more, so size the fix to the actual latency sensitivity of the workload rather than applying it fleet-wide. Steal is also intermittent and host-dependent, a fix validated on one host doesn't guarantee the next host you land on after any restart or migration behaves the same, so ongoing monitoring of the steal metric itself belongs in the long-term fix, not just a one-time check.
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 34 Performance Troubleshooting & Incident Response interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.