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.
A user updates their profile in Service A and immediately reads from Service B, and sees stale data. Enumerate the possible causes across caching layers, replication lag, eventual consistency, and API layering. Propose an immediate mitigation to reduce user impact and a long-term fix that provides read-after-write semantics for this use case.
Sample Answer
Direct answer. This is the classic read-your-own-writes problem: the write to Service A and the read from Service B are hitting different copies of the data, and the fix depends on WHY those copies disagree, which could be caching, replication lag, or a genuine architectural boundary between the two services.
Structured elaboration.
- Rule causes in or out with targeted checks. If Service B has its own cache in front of its data store, check whether the stale value is coming from that cache (a cache with a TTL that hasn't expired yet would explain it cleanly) versus from B's underlying data store itself. If B reads from a database replica, check replication lag between the primary (which A wrote to) and the replica B read from at that moment.
- Distinguish 'lag' from 'architectural boundary'. If A and B share the same underlying data store, this is a caching or replication-lag problem with a relatively contained fix. If A and B genuinely own separate data stores and B's copy is populated asynchronously (an event, a sync job) from A's, the staleness is a designed property of the system, not a bug, and the fix is either making that sync faster or explicitly changing the guarantee the API offers.
- Check the API layer itself, not just caching and the data store. If B's read goes through an API gateway, a BFF (backend-for-frontend), or any intermediate service that caches responses (an HTTP cache respecting a
Cache-Controlheader, a CDN sitting in front of B's API, or an aggregation layer that batches and caches reads), that layer can serve a stale response even when B's own data store is already fully up to date. This is worth ruling out early since it has a different fix (a cache-busting header, a shorter TTL, or an explicit invalidation call at the gateway) from either a data-layer cache or replication lag. - Immediate mitigation to reduce user impact. If it's cache-related, a short-TTL or explicit cache invalidation on write is a fast, contained fix. If it's replication lag, routing reads for RECENTLY-written data to the primary (or a replica known to be caught up) for a short window after a write is a common, working pattern.
- Long-term fix for read-after-write semantics specifically. Session-level read-your-writes (track that this specific user/session just wrote, and route their next few reads to the primary or a lag-free path) is more targeted than routing everyone to the primary always, which would defeat the purpose of having read replicas or a cache at all.
Worked example. Suppose checking replication lag at the exact timestamp of the read shows the replica B queried was about 800ms behind the primary at that moment, and the user's read happened roughly 400ms after their write. That 400ms gap is well inside the 800ms lag window, so the read genuinely landed before B's replica had caught up: a real, if unlucky, timing collision rather than a bug in either service's logic. If lag is USUALLY well under 400ms and this was an outlier (say, a spike caused by a large batch write elsewhere competing for replication bandwidth at that moment), the immediate fix is investigating and reducing what causes those lag spikes; if lag routinely runs in the 400-800ms range, this isn't a rare edge case, it's a frequent user-visible problem, and session-level read-your-writes routing is the more appropriate fix regardless of the spike's cause.
Trade-offs and pitfalls. Routing ALL reads to the primary to guarantee freshness is the simplest fix but defeats the purpose of having replicas (which exist to spread read load), so it's rarely the right default; targeted, session-scoped read-your-writes gets most of the user-experience benefit at a much smaller cost. It's also worth being honest with product and API consumers about which guarantee you're actually offering: 'eventually consistent, usually within X ms' is a real and often acceptable contract, but only if it's stated, not silently assumed.
You have an intermittent race condition in production producing duplicate orders, and staging cannot reproduce it at any realistic scale. Design a safe reproduction approach using traffic mirroring, controlled chaos, synthetic requests, and feature flags. Explain how you'd collect deterministic traces of the bug, how you'd disable write-through side effects while testing, and how you'd protect user privacy when mirroring production traffic.
Sample Answer
Direct answer. Reproducing a rare race condition safely in production traffic (since staging can't trigger it at scale) means observing real traffic patterns without letting your reproduction attempt cause the very duplicate-order side effect you're investigating, which is the central design tension of this whole approach.
Structured elaboration.
- Traffic mirroring, done safely. Mirror a copy of real production traffic to an isolated environment where you can instrument heavily, but the mirrored copy's WRITES must not actually reach production systems (the real order-processing backend, payment systems, inventory), since the goal is deterministic observation, not adding more real, uncontrolled write traffic to the very system you're debugging.
- Controlled chaos to increase the odds of triggering it. Since the bug requires a specific timing collision to manifest, deliberately introducing controlled variability (slight, bounded delays or reordering in a test harness) into the mirrored environment can increase how OFTEN the race condition's triggering conditions occur, without touching real production behavior at all, making the rare bug reproducible on a much shorter timescale than waiting for it to happen naturally.
- Synthetic requests as a complementary technique. Once you have a hypothesis about the specific timing window involved, purpose-built synthetic requests that deliberately try to land within that window (sent to the same isolated, non-production-writing environment) can confirm the hypothesis far more directly than waiting for mirrored real traffic to happen to collide the right way.
- Feature flags as the control and safety layer. Feature flags are what let you turn the other three techniques on and off without a deploy: gate the heavier instrumentation and controlled-chaos injection so they only apply to mirrored or synthetic traffic, never to real production requests, and give yourself an instant kill switch that can disable the whole reproduction harness in seconds if anything about it starts behaving unexpectedly. A flag is also a second, independent layer on top of the write-stubbing itself: structure it so a request can only reach the write-stubbed path if it's carrying a flag that marks it as part of this investigation, so a bug in the stubbing logic alone isn't the only thing standing between the reproduction attempt and a real write.
- Deterministic trace collection. Ensure the isolated environment captures full, high-fidelity traces (not sampled) for every request during the investigation, since you specifically need to see the exact interleaving of events that led to a duplicate, and a sampled trace might simply miss the one request pair that mattered.
- Disabling write-through effects during testing. This is the mechanism that makes the whole approach safe: the mirrored/synthetic environment needs its outbound calls to real downstream systems (anything that would actually create an order, charge a card, or update inventory) intercepted and stubbed, so the investigation can observe the RACE CONDITION's logic playing out without any of its side effects actually happening.
- Privacy when mirroring production traffic. Real production traffic contains real customer data; mirroring it for debugging needs the same data-handling discipline as production itself (access controls, retention limits, ideally scrubbing or tokenizing sensitive fields that aren't needed for this specific investigation), not a looser standard just because it's 'for debugging'.
Worked example. Suppose the hypothesis is that the race occurs when two requests for the same order ID arrive within a roughly 5 to 10 millisecond window (perhaps from a client that mistakenly double-submits, or a retry that fires just as the original request is completing). A synthetic test harness that intentionally sends two identical order-creation requests with a controlled, sweeping delay between them (testing 1ms, 5ms, 10ms, 20ms gaps against the isolated, write-stubbed environment) can map out the exact window where the duplicate actually occurs, turning a rare, unpredictable production event into a reliably reproducible one within the test harness, letting you confirm both the root cause and, later, that a fix actually closes the window across the whole range you tested.
Trade-offs and pitfalls. The single most important discipline in this whole approach is making absolutely certain the mirrored or synthetic environment's write-through paths are genuinely stubbed, not just believed to be; a mistake here would mean 'safe reproduction testing' actually creates real duplicate orders in production, which is the exact harm you're trying to investigate, now caused by the investigation itself. It's also worth budgeting real time for the privacy work (scrubbing or tokenizing mirrored customer data) rather than treating it as an afterthought, since skipping it to move faster creates a real compliance and trust risk for the sake of debugging convenience.
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 production service became partially available after an upstream dependency experienced a network partition: some requests succeed, others hang. Describe a step-by-step investigation and mitigation plan, covering short-term actions to restore consistency and long-term fixes to prevent recurrence, including what telemetry and logs you would examine and what temporary mitigations you might deploy.
Sample Answer
Direct answer. Requests hanging (rather than failing outright) after a network partition is a specific and important clue: it usually means a caller is waiting on a connection or response that will never arrive because the far side is unreachable, not that the far side is actively rejecting requests, so the mitigation has to focus on TIMEOUTS as much as on the partition itself.
Structured elaboration.
- Confirm the partition's scope. Which specific network path or region boundary is affected, and which services or calls cross it? A partition rarely means 'everything is down'; it usually means 'calls crossing this specific boundary are affected', and calls that don't cross it should be unaffected. Concretely, this means checking per-destination error-rate and latency dashboards (segmented by downstream service and region) to see exactly which calls are degraded, connection-pool and thread-pool utilization/saturation metrics to see which resources are being tied up by hung requests, host- and network-level logs (TCP connection resets, SYN timeouts, retransmission counts) to confirm packets genuinely aren't getting through rather than just running slow, and any circuit-breaker or timeout-trip logs that are already firing, since those tell you which calls the system itself has already identified as failing.
- Understand why some requests succeed and others hang. Requests that don't need to cross the partition succeed normally. Requests that DO need to cross it will hang if there's no timeout configured on that call, or fail relatively quickly if there is one; a service with inconsistent timeout configuration across its various outbound calls will show exactly this kind of mixed 'some succeed, some hang' pattern.
- Immediate mitigation. Apply or tighten timeouts on the specific calls that cross the partition, so hanging requests fail fast instead of consuming resources (a connection, a thread, a request slot) indefinitely; a service where every incoming request eventually hangs waiting on an unresponsive downstream can exhaust its own capacity even though ITS code has no bug. If there's a fallback path or cached data available, serving degraded results instead of hanging is often better for users than waiting.
- Longer-term fixes. Ensure every outbound call has an explicit, sane timeout as a standing practice, not just for this partition. Add circuit breakers so that once a downstream is detected as unreachable, subsequent calls fail immediately instead of each one re-attempting the same doomed wait. Consider whether critical paths need a documented fallback behavior for partition scenarios specifically (serve stale data, degrade a feature, queue the write for later) rather than leaving the behavior undefined and discovering it live during an incident.
- Restore consistency once the partition heals. Any writes that were queued, retried, or that partially succeeded during the partition need reconciliation: check for duplicate side effects (from client-side retries during the hang), and confirm read paths are serving current data again, not still routed to a stale fallback.
Worked example. Suppose the partition separates region A from region B, and a payment service in region A calls a fraud-check service in region B with no configured timeout on that specific call. Requests through the normal path (fraud-check reachable) take their usual 30 to 50ms; requests during the partition hang until the underlying TCP connection itself times out, which at the OS level might take 60 to 130 seconds by default, far longer than any reasonable user-facing request should ever wait, and each hung request holds a thread or connection slot the whole time. Adding an explicit 2-second application-level timeout on that specific call (well above its normal 30 to 50ms but far below the OS default) means a partitioned call fails fast, freeing the resource, rather than hanging for over a minute; combined with a circuit breaker, subsequent calls during the same partition would fail immediately without even attempting the call, once the breaker trips.
Trade-offs and pitfalls. Setting timeouts too aggressively can cause false failures during normal, brief latency blips, so the value needs to be based on the call's actual normal latency distribution, not an arbitrary round number. It's also worth checking whether the SAME issue (missing or overly long timeouts on cross-partition calls) exists on other calls beyond the one that caused this specific incident, since a partition is exactly the kind of event that exposes every under-configured timeout across a system at once.
Your telemetry shows a sharp increase in intermittent 429 rate-limit responses right after a partner integration launched. As the engineer owning the API, describe how you'd diagnose the problem, including how you'd coordinate with the partner to isolate whether the cause is on your side or theirs, and the short-term mitigations you'd apply while a fix is worked out.
Sample Answer
Direct answer. A rate-limit spike right after a partner integration launch is a strong, specific correlation, but confirming it (rather than just assuming it) and figuring out which side needs to change is the actual diagnostic work, since 'their new integration' could mean several different things technically.
Structured elaboration.
- Confirm the correlation precisely. Check whether the 429 spike is genuinely concentrated on requests from the partner's integration specifically (by API key, client ID, or whatever identifies their traffic) versus a broader, coincidental increase across all callers; this rules out a red herring where the timing matches but the actual traffic source doesn't.
- Rule out a cause on your own side, not just theirs. Before treating the partner's traffic as the mechanism, check whether anything changed on YOUR side around the same time: a recent deploy that altered a rate limiter's default thresholds or a shared config value, a pooled or shared quota bucket that unrelated traffic is also drawing from (so the partner's launch is coincidental timing, not the actual cause), or a bug in how the rate limiter attributes or counts requests that's inflating the count for otherwise-normal traffic. This is what the coordination step below is actually for: if the partner's measured rate turns out to be well within your own documented limits once you look closely, that combination, correlated timing but no real limit violation, is itself the strongest signal the cause is on your side, not theirs.
- Understand the partner's actual request pattern. Is their traffic volume simply higher than expected (a legitimate but larger-than-anticipated load), or is their pattern inefficient in a specific way (polling far more frequently than necessary, not respecting a documented rate limit, retrying aggressively on their own 429 responses in a way that compounds the problem, or making redundant calls that could be batched or cached on their end)? Reviewing their actual call patterns (timing, frequency, whether calls are cacheable but aren't being cached) answers this.
- Coordinate with the partner using specific evidence. Share concrete data: their actual request rate against your documented limits, the specific pattern (if any) that's inefficient, and what a compliant integration would look like; specific, evidence-backed feedback is far more actionable for them than a general 'you're causing errors' report.
- Short-term mitigations while a proper fix is worked out. If their volume is legitimate but exceeds current limits, a temporary limit increase (if your infrastructure can absorb it safely) avoids blocking their real business need while a more durable fix is designed. If their pattern is inefficient, helping them add basic client-side caching or reduce polling frequency, even as a stopgap before a deeper fix, reduces load quickly without your side needing to change anything.
Worked example. Suppose reviewing the partner's call pattern shows they're polling a specific endpoint every 2 seconds per user session to check for status updates, when the underlying data they're polling for typically only changes every few minutes; that's a classic inefficient-polling pattern, not a legitimate high-volume need. Recommending they either reduce polling frequency to something more proportional to how often the data actually changes, or better yet, move to a webhook or push-notification mechanism if your API offers one, would cut their request volume dramatically (potentially by 90% or more, if polling every 2 seconds versus needing an update roughly every few minutes) without requiring any change to your own rate limits or infrastructure at all.
Trade-offs and pitfalls. Simply raising rate limits for a partner without first understanding WHY they're hitting them treats the symptom, not the cause, and can mean you're now absorbing genuinely wasteful traffic indefinitely, which costs you infrastructure capacity for no real business benefit on either side. It's also worth building this kind of check (comparing new-integration traffic patterns against expected, efficient usage) into your partner-onboarding process going forward, so an inefficient pattern like aggressive polling is caught and corrected before launch rather than discovered from a live 429 spike after the fact.
Unlock Full Question Bank
Get access to all 32 Production Incident Diagnosis and Distributed Systems Troubleshooting interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.