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.
In Kubernetes, a pod shows CPU throttling (cpu.cfs_throttled_periods increased). Describe why throttling happens, how it affects latency, and three actions you can take to investigate and mitigate the impact on the service.
Sample Answer
Direct answer: CPU throttling in Kubernetes happens because a container's CPU limit is enforced through the Linux kernel's CFS (Completely Fair Scheduler) quota and period mechanism: if a container tries to use more CPU time than its quota allows within a fixed period (100ms by default), the kernel pauses it until the next period starts, even if the node itself has idle CPU capacity elsewhere. That pause shows up as latency spikes, especially in the tail (p99, the 99th percentile: the slowest 1% of requests, which absorbs a stall like this well before it moves the average), because a request that happens to run during a throttled window simply stalls.
Structured elaboration:
- Why it happens: a CPU limit of, say, 500m (half a core) with the default 100ms period gives the container a 50ms quota per period. If the workload bursts to use more than that within a single period, cgroups throttles it for the rest of that period regardless of whether other cores on the node are idle.
- Effect on latency: average CPU usage can look modest (say 20 to 30 percent) while individual requests still hit long stalls, because throttling is measured against short bursts inside a 100ms window, not against a smoothed average. This hits multi-threaded or highly concurrent runtimes hardest, since parallel work can burn through a small quota very quickly.
- Three actions:
- Investigate: check
container_cpu_cfs_throttled_periods_totalagainstcontainer_cpu_cfs_periods_total(exposed via cAdvisor/kubelet metrics) to quantify how often throttling is happening, and correlate throttled windows against the p99 latency graph to confirm they line up. - Mitigate immediately: raise the CPU limit to give more quota per period; this is usually the fastest safe production change, but be precise about what it costs, because the usual explanation is wrong. The scheduler fits pods onto nodes using their CPU requests, never their limits, so raising a limit on its own does not change how many pods fit on a node at all. What it changes is how much CPU the pod can take when it wants it, which means the sum of limits on a node can now exceed the node's real capacity and the pods contend at peak instead of being spread at scheduling time. Two knock-on effects are real and worth deciding deliberately: raising the limit without raising the request drops the pod out of the Guaranteed QoS class (which requires request to equal limit) into Burstable, making it a more likely eviction candidate under node memory pressure; and if you raise the request to match, then you genuinely are reserving more per pod, and only then do bin-packing and cost move.
- Fix at the application layer: check whether the runtime's own concurrency setting (for example Go's GOMAXPROCS, or a thread pool size) is set higher than the CPU limit, which causes the app to schedule more parallel work than the limit can actually support within a period, making throttling worse than the limit alone would suggest; right-size that setting to match the limit.
- Investigate: check
Worked example: A pod has a CPU limit of 500m with the default 100ms period, giving it a 50ms quota per period. A request handler spins up four goroutines that together try to use close to four cores' worth of CPU time within the same wall-clock window. At that rate the container burns through its 50ms quota after only about 12.5ms of wall time and is throttled for the remaining 87.5ms of that period, even though the node has spare cores sitting idle. cpu.cfs_throttled_periods climbs sharply at the exact times p99 spikes. As an immediate mitigation, the limit is raised to 1000m (doubling the per-period quota, though a genuine four-way burst can still exceed even that); as the more complete fix, GOMAXPROCS is set explicitly to match the container's CPU allocation instead of the node's total core count, so the runtime stops scheduling more parallel work than it can actually use inside a period.
Trade-offs and pitfalls: raising CPU limits across the board is not free, but the cost is not where it is usually placed. Because scheduling is driven by requests, raising limits alone oversubscribes each node rather than shrinking its pod count, and you discover that at peak rather than at scheduling time; raising requests alongside them is what actually reserves more capacity per pod, reduces how many pods fit per node, and raises the bill. Decide explicitly which of the two you are changing and say so, because "we raised the limits" and "we raised the requests" have opposite failure modes. Removing the CPU limit entirely avoids throttling but leaves nothing stopping one pod from starving its neighbors under node-level CPU pressure, since a CPU request only controls where the pod fits and its proportional share of CPU once the node is contended, never a hard ceiling; that trade-off needs a cluster-level capacity conversation, not a silent per-service change.
Given a Linux server showing high 'load average' values, list and describe the sequence of quick checks and commands you run in the first 10 minutes to determine whether the problem is CPU bound, IO bound, memory bound, or network bound. Include specific commands and what you'd look for in their output.
Sample Answer
Direct answer: A high load average alone doesn't tell you which resource is the bottleneck, because on Linux the load average counts both CPU-runnable processes and processes stuck in uninterruptible sleep waiting on I/O. The first ten minutes should systematically pull apart CPU, memory, I/O, and network signals instead of guessing from the load number by itself.
Structured elaboration, the first-ten-minutes checklist:
uptime: read the 1/5/15-minute load averages and compare against the number of CPU cores. A load of 8 on a 4-core box that's been climbing across all three windows means a sustained backlog, not a blip.toporhtop: look at the overall CPU split between user time (%us), system/kernel time (%sy), and I/O wait (%wa, CPU cycles reported idle because the CPU is actually blocked waiting on I/O).vmstat 1: thercolumn (runnable queue) versusb(processes blocked in uninterruptible I/O wait) tells you whether the backlog is compute-bound or I/O-bound.si/so(swap in/out) nonzero points to memory pressure.free -m: available memory and swap usage.iostat -x 1: per-device%utilandawait(average time a request waits, including queueing) tell you if a disk is saturated.- Network: reach for the right counter, because the two most commonly cited commands do not report what people think they do.
ss -sprints a socket-count summary by protocol and state, which is useful for spotting a pile-up in TIME-WAIT or SYN-RECV but contains no retransmit or error counters at all;sar -n DEVreports throughput only (packets/s, kB/s, %ifutil), so it stays clean while an interface is dropping frames. For retransmits usenstat -az | grep -i retransornetstat -s | grep -i retrans(fleet-level TCP counters) orss -tin(per-socketretrans:and congestion-window state); for interface errors and drops usesar -n EDEV; for TCP error and retransmit rates over time usesar -n ETCP; and for socket queue backlog read the Recv-Q and Send-Q columns ofss -ltn, where a persistently nonzero Recv-Q on a listening socket means the application is not accepting fast enough. - Route the conclusion: high
%waplus high disk%util/awaitpoints to I/O bound; high, sustained%uspoints to CPU bound; nonzero swap activity points to memory bound; otherwise check network error and retransmit counters.
CPU-specific deep dive. If the signal points to CPU, split it further. top's %us (time the app itself spends computing) versus %sy (kernel time: syscalls, context switches) versus %wa tells you what kind of CPU pressure it is. Run mpstat -P ALL 1 to check whether the load is spread evenly across cores or crammed onto one, since an averaged top view can hide a single core pegged at 100% while the rest sit idle, which a simple load-average number won't reveal either. pidstat -u 1 attributes CPU time to a specific process, and perf top (a statistical CPU profiler that samples which function is currently executing) narrows it down to the actual hot function once you've found the process.
Worked example: uptime shows load average 8.2, 7.9, 6.5 on a 4-core box, roughly double the core count and sustained across all three windows. top shows %wa=55, %us=10, %id=30. vmstat shows b=6 (six processes blocked). iostat -x shows sda %util=98, await=180ms. That combination rules out CPU: the CPU is mostly idle-waiting, not computing, and the disk is both saturated and slow to respond. The conclusion is I/O bound, and a CPU-focused fix like adding more app instances wouldn't help; the mitigation is either scaling the storage tier, offloading a write pattern, or hunting for a runaway process doing unexpected disk I/O.
Trade-offs and pitfalls: The most common mistake is reading a high load average as automatic proof of CPU pressure without checking the %wa split first. A second trap is trusting an averaged top view across all cores when a single hot core can be masked by idle ones; mpstat -P ALL catches that, a plain top summary line does not.
Explain how you would determine whether a latency regression is caused by increased contention (locks) versus increased garbage collection in a JVM service. Which metrics and tooling would you use and what patterns would confirm each hypothesis?
Sample Answer
Separate the two hypotheses by where the time is actually going: elevated GC (garbage collection, the JVM's automatic memory reclamation) shows up as measurable pause time and real CPU spent inside GC threads, while lock contention shows up as threads sitting BLOCKED waiting on a monitor (here, a monitor is the built-in lock object a thread must acquire to enter a synchronized block, not a monitoring or APM tool), with normal GC activity and often normal or even low CPU usage, since blocked threads aren't computing at all.
Metrics and tooling for the GC hypothesis
- GC logs (enabled with a flag like
-Xlog:gc*) showing pause frequency, pause duration, and what percentage of wall-clock time the process spends paused. jstat -gcutilfor live young/old generation occupancy and GC count and time.- A heap-usage graph with a sawtooth pattern climbing close to max before every collection, and collections becoming more frequent and longer, points to memory pressure driving GC.
- A flame graph (a visualization where the width of each bar shows how much time was spent in that function, making hot code paths easy to spot) or APM (application performance monitoring) tool showing GC threads consuming a meaningful share of total CPU.
Metrics and tooling for the lock-contention hypothesis
- Thread dumps (as described for reading BLOCKED-thread patterns) showing many threads funneling to one lock holder.
jstackor a JFR (Java Flight Recorder) contention profile giving monitor wait time per lock directly.- Latency degrading WITHOUT a corresponding rise in CPU usage or GC time is the key signature, CPU can even look under-utilized because threads are idle waiting rather than computing.
Confirming which one applies
- GC: pause times line up directly with the timing of the latency spikes (a spike coincides with a stop-the-world pause), and reducing allocation rate or retuning the GC algorithm reduces pause time and latency together.
- Lock contention: the regression tracks with rising concurrency (more threads means more competition for the same lock) rather than with memory pressure, and repeated thread dumps taken during the slow window show the same BLOCKED pattern every time.
Worked example: p99 latency (99th percentile: the value below which 99% of requests fall) degrades from 80ms to 400ms under peak traffic. GC logs show average pause time unchanged at 15ms and pause frequency unchanged from the healthy baseline, ruling out GC as the driver. Three thread dumps taken 5 seconds apart during the slow window all show more than 30 threads BLOCKED on the same synchronized cache-refresh method, confirming lock contention: the cache lookup logic was holding a lock for the entire refresh instead of only while swapping the reference.
Trade-offs and pitfalls: the two causes can co-occur, heavy contention can force more object retention which then increases GC pressure, so treat the first hypothesis that fits the evidence as a starting point, not a final answer, and re-check after any fix lands. A common mistake is reading normal CPU utilization as proof it "must be locks" without checking a GC log, since a moderately sized heap can still produce infrequent but very long pauses that a coarse CPU average won't reveal.
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.
You're on-call and receive an alert that only users in one geographic region are experiencing errors and high latency while other regions are fine. Provide a prioritized runbook of troubleshooting steps to isolate whether the problem is network-level, region-specific cloud infra, or application-level. Include quick mitigations to restore service and what telemetry you would gather for post-incident analysis.
Sample Answer
Direct answer: When only one region shows errors and latency while the rest are fine, and your application code is presumably identical across regions, the fastest path is to check the cheapest, most likely regional causes first, provider status, network path, regional infrastructure health, before assuming it's an application bug.
Structured elaboration, a prioritized runbook (a step-by-step checklist for handling this specific type of incident):
- Check the cloud provider's status page for that region first. It's the cheapest possible check: is there a known provider-side incident already?
- Check the regional network path. DNS resolution and routing into that region, and load balancer or CDN health checks specific to that region's edge nodes, ideally from more than one vantage point.
- Check regional infrastructure health. Are the compute instances or pods in that region's cluster healthy (node status, restart counts), and is a region-pinned dependency, like a regional database replica or cache, degraded?
- Only then suspect application-level causes. If network and infrastructure both look clean, check whether that region is running a different deploy version, config, or feature-flag state than the healthy regions; region-scoped rollouts are common and easy to overlook.
- Quick mitigations: if your architecture supports it, fail over that region's traffic to a healthy region via DNS or a global load balancer, the fastest way to restore service, at the cost of added latency and possibly data-locality considerations for those users. If failover isn't available, scale up capacity in that region in case it's a capacity issue, or roll back a region-scoped deploy if one is found.
- Telemetry to capture for post-incident analysis: the exact start and end time of impact, provider status-page timestamps if there was an outage, per-region deploy and config diffs at the time, the traffic-shift decisions and their timestamps, and an estimate of customer impact (percent of traffic, duration).
Worked example: The provider status page shows nothing unusual. Synthetic probes hitting that region's load balancer show elevated TCP connect time, about 150ms versus 5ms elsewhere, pointing at the network rather than the application. Checking that region's routing configuration turns up a routing-table change pushed a few hours earlier that unintentionally restricted a previously direct path, adding extra hops. As a quick mitigation, that region's traffic is failed over to the next-nearest healthy region via the global load balancer, accepting added latency for those users temporarily, while networking reverts the routing change; traffic is failed back once synthetic probes confirm connect times have returned to baseline.
Trade-offs and pitfalls: failing traffic over to another region isn't free, it adds latency and can conflict with data-residency requirements for that user base, so it needs a fast, deliberate go or no-go decision, not silence. Checking application-level causes last is a deliberate ordering choice (cheapest and most likely first), not a reason to skip it: if network and infrastructure both check out clean, a region-scoped rollout is a very common actual cause and needs to be explicitly ruled in or out, not assumed innocent just because "the code is the same everywhere."
Unlock Full Question Bank
Get access to all 24 Performance Troubleshooting & Incident Response interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.