Production Incident Diagnosis and Distributed Systems Troubleshooting Questions
Debugging distributed systems under fire: diagnosing latency and reliability regressions, root-causing across service boundaries, reading traces and metrics during an incident, and reasoning about complex production failures. Covers the investigative method for hard-to-reproduce, multi-service problems. The operational counterpart to resilient design.
You see conflicting observability signals: tail latency (p95) is up, but the overall error rate is down and throughput is steady. Walk through how you would investigate this, what quick experiments or probes you would run, and how you'd make an operational decision while minimizing customer impact.
Sample Answer
Direct answer. Since throughput and overall error rate look fine, the tail-latency increase is most likely confined to a specific subset of requests rather than a system-wide degradation, so the investigation should look for what's different about that slice before considering any broad, system-wide action.
Structured elaboration.
- Isolate what's actually in the slow tail. Filter to the specific requests contributing to the p95 increase and look for a shared trait: a specific endpoint, customer, payload characteristic, or time-of-day pattern, the same filter-to-the-outliers-and-look-for-a-shared-trait method that works for any tail-only latency regression.
- Run quick, low-risk probes rather than broad changes. A synthetic request against the suspected slow path, or comparing a handful of real slow requests' traces against a handful of fast ones for the same endpoint, can confirm or rule out a hypothesis in minutes without touching production configuration.
- Consider that a healthy aggregate can mask a real, contained problem. Overall error rate being down and throughput being steady are reassuring but don't rule out a genuine issue affecting a minority of requests badly enough to move p95 without moving the headline numbers; don't let the healthy aggregate talk you out of investigating.
- Make an operational decision under uncertainty, prioritizing customer impact. If the affected slice is small and its impact on real users is mild (a moderate latency increase, not outright failures), it may be reasonable to keep investigating without an urgent mitigation. If the affected slice, though small in volume, represents a high-value case (a specific large customer, a critical workflow), a more urgent, even if narrowly-scoped, mitigation is warranted despite the healthy aggregate.
- Avoid overcorrecting based on an aggregate metric alone. Since error rate is actually down, a broad rollback or a wide mitigation aimed at 'fixing everything' risks solving a problem that doesn't exist system-wide while potentially disrupting the parts that are currently working fine.
Worked example. Suppose filtering the slow requests contributing to the p95 increase shows they're concentrated on one endpoint that recently started making an additional downstream call for a subset of requests (say, an enrichment lookup that only fires when a specific optional field is present in the request). That call adds real latency only for the requests that trigger it, which is small enough as a fraction of total traffic to leave overall throughput and error rate essentially unchanged, while still being large enough within that specific slice to move the overall p95. The operational decision, since the enrichment call isn't failing (which is why error rate is unaffected) and only some requests need it, might be to make that specific call async or cached rather than synchronous and blocking, targeting the fix at the actual mechanism rather than anything system-wide.
Trade-offs and pitfalls. The main risk here is either extreme: dismissing a p95 anomaly because the aggregate looks healthy, or overreacting with a broad, disruptive mitigation because ANY anomaly feels alarming. The middle path, quickly isolating the affected slice and matching the response's urgency and scope to what you actually find, protects users without unnecessary disruption to the parts of the system that are working fine.
A critical API shows intermittent authentication failures logged across multiple regions. Design a troubleshooting plan that includes hypothesis generation, quick experiments to isolate the responsible component (the identity provider, the network, or the client SDK), and a safe rollback path if a configuration change turns out to be the cause.
Sample Answer
Direct answer. Multi-region intermittent auth failures need a component-isolation approach: the identity provider, the network path, and the client SDK are three independent things that could each cause exactly this symptom, so the plan has to generate evidence that points at ONE of them specifically rather than guessing.
Structured elaboration.
- Form specific, testable hypotheses for each candidate component. Identity-provider issue: if the IdP itself is degraded or rate-limiting, its own health metrics or status page would show it, and the failures should correlate with IdP-side load or incidents rather than any property of your own regions. Network issue: if it's connectivity between specific regions and the IdP, the failures should correlate with WHICH region a request originates from, not with any property of the request itself. Client SDK issue: if a specific SDK version has a bug (a token-refresh race condition, a misconfigured timeout), the failures should correlate with SDK version or client type, regardless of region or IdP health.
- Run quick, targeted experiments to test each hypothesis. A synthetic auth request sent directly to the IdP from each region, bypassing the normal client SDK entirely, isolates whether the failure reproduces without the SDK in the loop (ruling the SDK in or out). Comparing failure rates specifically by originating region isolates whether it's network-related. Comparing failure rates by SDK version (if you have multiple versions deployed, which is common during a rollout) isolates whether it's a client-side bug.
- Correlate against the intermittency pattern itself. Is the intermittency correlated with TIME (suggesting a periodic issue, like a token-refresh cycle or a scheduled IdP maintenance window) or genuinely random? A time-correlated pattern narrows the search significantly.
- Safe rollback path if a configuration change is the cause. If recent evidence points at a configuration change (an IdP-side setting, a network policy, an SDK config value) that coincides with when the intermittent failures started, have a tested, fast path to revert that specific change, and validate that reverting it actually resolves the failures in at least one affected region before considering it confirmed and rolling the revert out everywhere.
Worked example. Suppose the synthetic direct-to-IdP requests (bypassing the SDK) STILL show the same intermittent failure pattern in every region, at roughly the same rate as normal traffic. That rules out the SDK as the cause: removing it from the request path didn't change the outcome, so whatever's failing is happening somewhere both the normal client and the synthetic test share, meaning the IdP itself or the network path to it. Comparing THOSE bypass-test failure rates by region next shows they're concentrated specifically in regions whose traffic to the IdP crosses a specific network peering link that was recently reconfigured, rather than spread roughly evenly across every region the way a genuine IdP-side problem would be. That converges the investigation on the network path for that specific link, not the IdP (which would show up everywhere, not just in these regions) or the SDK (already ruled out by the bypass test still failing), and the next step is working with network or infrastructure teams to examine that peering link's health and recent changes specifically, armed with concrete regional correlation data rather than a vague 'auth is flaky sometimes' report.
Trade-offs and pitfalls. The key discipline here is running experiments that isolate ONE variable at a time (bypass the SDK to test IdP+network without the SDK; compare across regions to test network specifically); a hypothesis based only on correlation without an isolating experiment is much weaker evidence, since multiple candidate causes can correlate with the same rough time window without actually being the cause. It's also worth checking whether the SAME regions affected here have had OTHER, unrelated network issues recently, since infrastructure problems often cluster on the same underlying shared link or path.
Case study: you observe a cascading failure. Service A slowed down, which caused Service B to retry aggressively, which overloaded Service C and caused it to fail, which then triggered the control plane to restart pods. Describe how you would build the causal chain for the RCA, the immediate mitigations to stop the cascade, and the engineering changes (bulkheads, per-caller limits, circuit breakers, request queuing) you'd propose to prevent recurrence. Include how you would test that the fixes actually work.
Sample Answer
Direct answer. The causal chain runs forward through the system and the fix has to interrupt it at the right point: Service A slowed down, Service B's retries turned that slowdown into extra load on Service C, Service C failed under that load, and the control plane's restart of Service C then added a further disruption on top of an already-degraded system.
Structured elaboration.
- Reconstruct the timeline with timestamps, not just the sequence of events. Pull the exact moment each symptom started: when Service A's latency first rose, when Service B's retry rate and error logs started climbing, when Service C's error rate crossed its threshold, and when the control plane issued restarts. If Service B's retries start climbing within seconds of Service A's latency rising, and Service C's failures start climbing within seconds of Service B's retry volume rising, that timing is strong evidence for the causal chain, not just correlation.
- Find out why Service A slowed down in the first place, since everything downstream is a consequence, not an independent event: check its own logs, traces, and recent changes (deploy, config, traffic pattern) for the actual trigger.
- Examine Service B's retry configuration specifically. The chain only cascades because B retries AGGRESSIVELY: check its retry count, backoff strategy, and whether it has any concurrency limit or circuit breaker. A retry policy with no backoff and no cap will amplify A's slowdown into far more load on C than A's original traffic volume.
- Confirm C's failure mode. Was C's capacity simply exceeded (too much retried traffic for its provisioned capacity), or did the extra load trigger a secondary failure (for example exhausting its own connection pool or thread pool, or a resource leak that only manifests under load)? This distinguishes 'C needs more headroom or backpressure' from 'C has its own separate bug that load merely exposed'.
- Design the fix at each hop, not just at the origin. Fixing only Service A's original slowdown leaves the amplification mechanism (B's aggressive retries) in place for the next time something upstream degrades.
- Test that the fixes actually work, rather than assuming they do from the design alone. A load test or chaos experiment that reproduces the original trigger (deliberately slowing down a test instance of Service A, or injecting the same latency it originally had) and then confirms Service B's retry policy actually caps at the new limit, C's rate limiter holds under the resulting load, and B's circuit breaker actually trips when C is unhealthy, is the only way to know the fix works rather than assuming it from the design. Running this in a staging environment that mirrors production topology, rather than only reasoning about it on paper, is what turns 'we added a circuit breaker' into a verified fix instead of a hopeful one.
Worked example. Suppose Service A's latency rose because of a downstream database issue outside this chain, roughly tripling its response time. Service B calls A with a retry policy of 3 immediate retries and no backoff; under normal conditions A handles B's traffic at, say, 100 requests per second, but once A's latency triples, requests pile up waiting on A, B's client-side timeouts start firing, and B retries each one up to 3 times, meaning the effective load B is capable of generating against downstream systems (via its own calls to C, which happen per retry attempt) can multiply by roughly 4x (1 original attempt plus 3 retries) during the incident window. C, provisioned for A's normal 100 rps of downstream-triggered traffic, now faces closer to 400 rps and exhausts its connection pool, which is what causes its restarts. The fix has two parts: address A's original slowdown (its database issue), and separately fix B's retry policy to include exponential backoff with a cap and a circuit breaker so a slow A does not get amplified into 4x traffic against C the next time something upstream is slow.
Trade-offs and pitfalls. It's tempting to stop at 'Service A caused this' since it's first in the chain, but that misses that the SEVERITY of the incident (C failing, control-plane restarts) was driven by B's retry amplification, not by A's original slowdown alone; a much smaller upstream hiccup could have caused the same cascade with this retry policy in place. Bulkheads (isolating C's resources so one caller can't exhaust what other callers need), per-caller rate limits on C, and a circuit breaker in B (a check that stops calling a component once it has seen enough recent failures, so callers fail fast instead of piling up retries against something that's already down) are all defenses that stop the AMPLIFICATION rather than only the trigger, which is why they matter even once A's original problem is fixed. Request queuing at B (buffering excess calls behind a bounded queue rather than firing them at C immediately, so C sees a smoothed rate of demand instead of an instantaneous 4x spike) is a fourth lever worth having alongside the other three: it doesn't stop the retries from happening, but it decouples WHEN C actually sees that load from when B generated it, which helps when the amplification is bursty rather than sustained. A queue needs its own bound and an explicit shedding policy though, since an unbounded queue just turns a fast failure into a slower, memory-hungry one.
Compare strong consistency (for example linearizability) and eventual consistency from an SRE troubleshooting perspective. Discuss how each model affects availability and performance, the common failure modes each produces, and the kind of monitoring and alerting you'd set up to detect problems specific to each model.
Sample Answer
Direct answer. From a troubleshooting seat, the practical difference is what kind of anomaly each model produces and therefore what you'd actually alert on: strong consistency tends to fail as unavailability (the system refuses a request rather than serve a wrong answer), while eventual consistency tends to fail as staleness (the system serves an answer, just possibly an outdated one).
Structured elaboration.
- Availability and performance trade-offs. Strong consistency (linearizability) typically requires coordination among replicas before a read or write completes, which costs latency and, during a partition or replica outage, can mean the system refuses to serve requests rather than risk an inconsistent answer. Eventually consistent systems typically stay available and fast during the same conditions, at the cost of potentially serving stale data.
- Common failure modes, by model. A strongly consistent system's common failure mode is elevated latency or outright unavailability when coordination is slow or a quorum can't be reached; the system is 'failing safe' by refusing rather than guessing. An eventually consistent system's common failure mode is silent staleness: reads succeed and look normal, but the data may not reflect the latest write, and unlike an outright failure, this doesn't announce itself.
- What to monitor for strong consistency. Coordination latency (how long consensus or quorum operations take), quorum-availability metrics (can the system currently reach a quorum, meaning enough replicas to form the majority that must agree before a read or write is confirmed, and how close is it to not being able to), and the RATE of request rejections or timeouts due to coordination failure, since a rising rejection rate under strong consistency is your early warning of a coordination problem before it becomes a full outage.
- What to monitor for eventual consistency. Replication lag directly (the most direct proxy for how stale a read might be), and, where feasible, some measure of actual observed staleness (comparing values across replicas periodically, or tracking how often a read-after-write pattern actually returns fresh data) since lag alone doesn't tell you how often it actually causes a user-visible problem.
- Why this matters operationally. An SRE tuning alerts for a strongly consistent system should watch coordination health and rejection rates; an SRE tuning alerts for an eventually consistent system should watch lag and staleness directly, because 'the system is up and answering requests' tells you nothing about whether those answers are current.
Worked example. Consider two services with the same read volume: one backed by a consensus-based store (replicas must agree via a voting protocol before a change is committed), one by an asynchronously replicated store. During a network blip lasting 30 seconds, the consensus-backed service might show a spike in request latency or a burst of rejected writes (because it can't reach quorum), which shows up clearly as an availability dip on a standard error-rate dashboard. The asynchronously replicated service, during that same 30-second blip, would likely show NO change in its error rate or latency at all, because it keeps serving from local replicas regardless; the only signal would be a spike in replication lag, which is invisible unless you're specifically monitoring for it. A team that only tracks error rate and latency (assuming those catch every real reliability problem) would correctly catch the first service's incident and completely miss the second one, even though both experienced a real, if different, degradation.
Trade-offs and pitfalls. The common mistake is applying the same monitoring playbook (error rate and latency) to both kinds of systems and assuming that's sufficient; an eventually consistent system needs staleness-specific monitoring that a strongly consistent system doesn't, precisely because its failure mode doesn't show up as errors. It's also worth remembering these aren't the only two options: many real systems mix models (strong consistency for a narrow, critical write path, eventual consistency elsewhere), so the monitoring strategy often needs to match each PATH's actual guarantee, not the system as a whole.
Write a Python script that reads a log file where each line can contain a trace_id like '[trace_id=abc123]' and a log level. The script should print a summary of error counts per trace_id (count lines containing 'ERROR', grouped by trace_id). Example log lines:
2025-01-01T12:00:01Z [trace_id=abc123] ERROR Payment failed user=1234
2025-01-01T12:00:02Z [trace_id=def456] INFO Processed
Provide working Python code.
Sample Answer
Direct answer. The task is a straightforward parse-count-group problem: read each line, pull out the trace_id if present, check whether the line is an ERROR line, and maintain a running count keyed by trace_id.
Structured elaboration.
- Parsing the trace_id. A regular expression matching the literal pattern
[trace_id=...]reliably extracts the ID regardless of what else is on the line, which is more robust than assuming a fixed column position, since log lines can vary in format around the trace_id field. - Detecting an ERROR line. Checking for the literal substring
'ERROR'in the line, as the prompt specifies, is simple and sufficient here; a more defensive version might check it's a distinct token (not part of a longer word) but the given requirement is a straightforward substring/level check. - Aggregating. A dictionary (or
Counter) keyed by trace_id, incremented once per matching ERROR line, naturally produces the required summary; lines without a parseable trace_id should be handled explicitly (skipped, or bucketed under a sentinel key) rather than silently causing an error. - Output. Printing the counts, sorted for readability, gives a clear, deterministic summary regardless of the input's original ordering.
Worked example (executed).
import re
from collections import Counter
def count_errors_by_trace_id(lines):
pattern = re.compile(r"\[trace_id=([^\]]+)\]")
counts = Counter()
for line in lines:
if "ERROR" not in line:
continue
m = pattern.search(line)
if not m:
continue
trace_id = m.group(1)
counts[trace_id] += 1
return counts
sample_lines = [
"2025-01-01T12:00:01Z [trace_id=abc123] ERROR Payment failed user=1234",
"2025-01-01T12:00:02Z [trace_id=def456] INFO Processed",
"2025-01-01T12:00:03Z [trace_id=abc123] ERROR Retry failed user=1234",
"2025-01-01T12:00:04Z [trace_id=ghi789] ERROR Timeout user=5678",
"2025-01-01T12:00:05Z [trace_id=abc123] INFO Retrying",
]
counts = count_errors_by_trace_id(sample_lines)
for trace_id, n in sorted(counts.items()):
print(f"{trace_id}: {n}")
Running this against the sample lines above prints:
abc123: 2
ghi789: 1
def456 correctly never appears in the output, since its only line is INFO, not ERROR, and should not be counted.
Trade-offs and pitfalls. A naive substring check for 'ERROR' would also match a line that happens to contain the word 'ERROR' as part of unrelated text (an error MESSAGE mentioning the word without actually being an error-level log line, in an unusual logging format); if that's a real risk in your actual log format, matching a proper level field (like a leading ERROR token) is more robust, but the given requirement here is the simple substring form. It's also worth deciding explicitly how to handle a line with 'ERROR' but no trace_id (silently skipping it, as this implementation does, versus counting it under an 'unknown' bucket), since in a real incident you'd want to know if a meaningful fraction of your error lines have no trace_id at all, which would itself be a gap worth fixing in your logging.
Unlock Full Question Bank
Get access to all Production Incident Diagnosis and Distributed Systems Troubleshooting interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.