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.
During a high-severity incident, stakeholders demand immediate mitigation but engineers need time for a deep diagnosis. Describe how you would coordinate short-term mitigations, preserve and collect forensic performance data (heap, stacks, traces) without losing evidence, communicate status to stakeholders, and decide when to escalate to specialized teams. Provide a concise checklist and suggested stakeholder update cadence.
Sample Answer
Direct answer: Split the incident into two tracks that don't block each other: an Incident Commander (IC, the single person owning decisions and stakeholder communication, distinct from whoever is hands-on debugging) driving mitigation on a fixed update cadence, and a diagnosis track explicitly told to preserve evidence before anything gets torn down or restarted.
Structured elaboration, a concise checklist:
- Name an IC immediately, even informally. This frees the engineer doing deep diagnosis from also having to field stakeholder pings.
- Mitigate in parallel with diagnosis, not instead of it. Apply the safest, most reversible mitigation first (a rate limit, a feature flag off, a rollback, a failover) to reduce customer impact while the diagnosis track keeps working.
- Preserve evidence before anything gets torn down. If an instance is about to be restarted, scaled down, or killed, capture a heap dump (a snapshot of everything the application currently has allocated in memory) and a thread or stack dump (what every thread is doing at that instant, useful for spotting a stuck lock or a hot loop) plus a sample of traces from the affected window first. If capacity allows, pull one instance out of load-balancer rotation and tag it "do not touch, forensic copy" rather than killing it outright.
- Communicate on a fixed cadence, not ad hoc. A reasonable default during an active Sev-1 (severity 1, the highest classification, meaning significant customer impact) is an update every 15 to 30 minutes, even when the update is "still mitigating, no new information." Each update should state current customer impact, what's been tried, what's next, and when the next update will come.
- Escalate on either evidence or a clock, whichever comes first. Escalate to a specialized team once you have a specific, testable hypothesis that only they can confirm, or once the investigation needs access or tooling the incident responders don't have. Also set a time-box (30 to 45 minutes is reasonable) and escalate automatically if it passes without a working mitigation or a narrowing root cause, rather than waiting until you feel certain.
Worked example: A checkout service is failing for about 15% of requests during a flash sale. An IC is named within two minutes. At minute five, the day's newest feature flag is rolled back as mitigation, dropping impact from 15% to 4%, while in parallel one struggling instance is pulled from the load balancer (not killed), and a heap dump plus five minutes of trace samples are captured from it. Stakeholder updates go out every 15 minutes: "4% of checkout requests still failing, down from 15%, cause under investigation, next update in 15 minutes." At the 30-minute mark, the forensic data shows a lock-contention pattern inside a payment-validation library shared with the database team, a specific, testable hypothesis outside the on-call engineer's own code ownership, so the database team is looped in at that point instead of the on-call engineer trying to debug someone else's library alone.
Trade-offs and pitfalls: fixed-cadence updates can feel like overhead when there's genuinely nothing new; send them anyway, since "no change" is still information that stops five people separately pinging for status. Pulling an instance out of rotation for forensics reduces available capacity during an active incident, a real trade-off to weigh against how many replicas you have to spare. Escalating late because "we're close" is a common trap; use the time-box as a forcing function rather than trusting a feeling of how close the investigation is.
You see an increase in tail latency caused by client-side retries generating request storms to the backend. Propose short-term mitigations and long-term design changes (protocol, retry policy, back-pressure) to prevent retry amplification from causing cascading failures.
Sample Answer
Direct answer: Client-side retries generating request storms is retry amplification: a slow or failing dependency causes a client to retry, which adds more load onto an already-struggling backend, making it slower still and causing even more timeouts and retries, a feedback loop that can cascade into a full outage. The short-term fix is to cap or slow retries; the long-term fix is to make the whole call chain backpressure-aware so a slowdown can't turn into a spiral in the first place.
Structured elaboration:
- Short-term mitigations:
- Cap total retry volume with a retry budget (for example, retries may not exceed 10% of the original non-retry request volume). State the denominator explicitly when you write the policy down, because "10% of total traffic", "10% of original traffic" and "10% of successful traffic" are three different ceilings and the first one is self-referential, since retries are part of total traffic. A budget breaks the amplification loop immediately because it is a hard cap rather than a slowdown.
- Shed load with a fast, explicit failure (a 503 response with a Retry-After header) instead of letting requests queue indefinitely, so clients get a clear back-off signal instead of timing out and retrying blindly.
- Add a circuit breaker (a safeguard that stops sending requests to a struggling dependency once its failure rate crosses a threshold) in front of the struggling dependency: after a threshold of failures, stop sending it traffic for a cooldown window instead of continuing to hammer it.
- Long-term design changes:
- Retry policy: exponential backoff with jitter (randomizing the delay so many clients don't retry in synchronized waves) plus a bounded retry budget per client and per fleet.
- Protocol: favor idempotent operations (retrying one produces the same end result as running it once, so a client can safely retry without causing duplicate effects like a double charge), and propagate a deadline end to end through the call chain, so a downstream hop knows how much time is left and stops doing work the caller has already given up on.
- Backpressure: admission control at the backend that rejects or sheds new work once its queue depth crosses a threshold, rather than accepting everything and degrading uniformly, paired with a client-side rate limiter that adapts to observed backend health.
Worked example: Baseline traffic is 1000 requests per second (rps), normally handled fine at p99 200ms. The backend degrades slightly (a downstream database hiccup), so 5% of requests, 50 rps, now exceed the client's 300ms timeout. With a naive "retry immediately up to 3 times" policy, those 50 rps of failures generate up to 50 times 3 = 150 extra rps of retries, pushing total load from 1000 rps to 1150 rps, a 15% increase exactly when capacity is already reduced. If the backend degrades further under that added load, say the failure rate doubles to 10% of everything it is asked to serve, do the accounting as a steady state rather than by stacking rounds, because the 150 rps of retries are already inside the 1150 and a second round computed on top of that total counts them twice. Let A be the total attempts per second the backend actually sees. Real user traffic is still 1000 rps and never changed, and every failed attempt spawns 3 retries, so A = 1000 + 3 x 0.10 x A, which rearranges to A = 1000 / (1 - 0.30) = about 1430 rps, roughly 43% above baseline from a user load that is completely flat. Writing it as a fixed point rather than as rounds is what makes it useful under pressure, because it tells you where the spiral stops being a spiral and becomes an outage: A = 1000 / (1 - 3p) has no finite solution once 3p reaches 1, so with a 3-retry policy any sustained failure rate at or above about 33% makes offered load diverge and the service cannot climb out on its own no matter how long you wait. That threshold, not the size of any one round, is what a retry budget exists to keep you away from. Capping retries at 10% of the original non-retry volume holds the worst case at 1100 rps regardless of how bad the failure rate gets, instead of letting it settle at 1430 rps or run away entirely.
Trade-offs and pitfalls: eliminating retries entirely trades away real resilience for amplification safety, since some transient errors genuinely should be retried; the fix is bounding and randomizing retries, not banning them. Backpressure done badly, a hard reject with no guidance, can look like an outage to callers that don't handle a 503 gracefully, so it needs to be paired with a documented client contract for what to do when throttled.
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 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.
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.