Debugging and Systematic Troubleshooting Questions
Diagnosing defects methodically: reproducing failures, forming and testing hypotheses, reading stack traces and logs, bisecting changes, and reasoning about error handling and edge cases. Covers a disciplined root-cause approach that applies from local bugs to production issues, distinct from embedded hardware-level debugging. A universally probed engineering-craft skill.
During a cloud migration to a managed Kafka service, end-to-end latency increased. Outline how you would isolate whether the latency is introduced by the network, broker configuration, producer throttling, or consumer processing, and propose mitigation steps for each possible root cause.
Sample Answer
Direct answer
Isolate whether Kafka-migration latency comes from network, broker configuration, producer throttling, or consumer processing by measuring each stage of the pipeline SEPARATELY, since end-to-end latency alone can't distinguish them, and by specifically comparing the new managed Kafka's configuration and network topology against the previous setup, since a "like-for-like" migration frequently isn't actually like-for-like in ways that matter for latency.
Structured elaboration
- Measure network latency to the new managed Kafka endpoint directly, independent of any Kafka-level activity: a simple round-trip-time check to the broker endpoints from the producer/consumer hosts; if this alone is elevated compared to the previous setup, the migration likely introduced a topology change (a different region/availability-zone placement, an extra network hop through a managed-service gateway) that accounts for some or all of the added latency before Kafka's own behavior is even a factor.
- Check broker AND producer-client configuration differences specifically. A managed Kafka service often ships with different DEFAULT settings than a previous self-managed or differently-configured cluster, on both sides of the wire. Broker/topic-level settings to diff include replication factor (how many copies of each partition are kept across brokers) and
min.insync.replicas(how many replicas must acknowledge a write before the broker considers it committed). Producer-CLIENT settings to diff includeacks(how many replicas the producer itself waits to hear back from before treating a write as complete, directly affecting produce latency, and working together with the broker'smin.insync.replicas) andlinger.ms(how long the producer buffers on its own side to accumulate a bigger batch before sending, trading a little latency for fewer, more efficient network round trips); these two are configured on the PRODUCER, not the broker, but a managed-service migration often resets the client library or its config to defaults too, so they're worth diffing alongside the broker's own settings. Diff the new service's actual effective configuration, on both the broker and the producer client, against the old setup's, rather than assuming defaults are equivalent on either side. - Check producer-side throttling. Managed Kafka services frequently enforce per-client or per-topic throughput quotas that a self-managed cluster may not have had (or had configured differently); check the producer's own client-side metrics for throttling indicators (many Kafka client libraries expose a specific throttle-time metric) directly, which would show unambiguously if quota enforcement is adding latency.
- Check consumer-side processing time, isolated from Kafka itself: instrument the consumer to measure time from "message received from Kafka" to "message fully processed," separately from any Kafka-side fetch latency; if this component alone has grown, the issue may be entirely on the consumer's own processing path (perhaps due to an unrelated change, or increased load) and not attributable to the Kafka migration at all, despite the timing correlation with the migration.
- Isolate systematically, changing one variable at a time if needed: if the above measurements don't cleanly attribute the latency to one stage, a controlled test (a minimal producer and consumer, doing nothing but round-tripping a message through the new Kafka service with no application logic involved) isolates Kafka/network-level latency from anything specific to the actual application's producer or consumer code.
Worked example
Direct network round-trip measurement to the new managed Kafka endpoint shows meaningfully higher latency than the old cluster, tracing to the new service being provisioned in a different availability zone than the application hosts, an oversight in the migration's provisioning step rather than anything about Kafka's own behavior. Producer-side throttle metrics also show non-zero throttling during peak periods, a SEPARATE contributing factor from a newly-enforced quota the previous self-managed cluster never applied. Both are confirmed as genuine, independent contributors (not just one masking the other) by measuring each in isolation: network latency alone accounts for a meaningful floor even during low-throughput periods when throttling shouldn't be a factor, while the throttling-driven latency shows up specifically during peak-throughput windows on top of that floor.
Mitigation matched to each confirmed cause: re-provision the application hosts (or request the managed service be provisioned) in the same availability zone to eliminate the network topology gap; request a quota increase (or restructure producer batching to stay under the current quota more gracefully) to address the throttling specifically. Both fixes are targeted at their own confirmed mechanism, rather than a single blanket change assumed to fix "the latency problem" as one undifferentiated issue.
Trade-offs and pitfalls
Assuming a SINGLE root cause when multiple independent factors are each contributing (as in this example) risks declaring victory after fixing only one of them, leaving a smaller-but-still-real regression in place and unexplained; measuring each candidate cause independently, rather than stopping investigation once ANY plausible cause is found, is what catches a multi-factor case like this one.
Describe a systematic, repeatable approach you use to troubleshoot an unfamiliar technical problem end to end. Cover how you observe the symptom, form and prioritize hypotheses, gather and interpret evidence such as logs, metrics, and traces, isolate the root cause, implement and validate a fix, and decide when to escalate, roll back, or write up a postmortem.
Sample Answer
Direct answer
Troubleshooting an unfamiliar problem is a loop, not a single step: observe the symptom precisely, form a small set of testable hypotheses ranked by likelihood and cost to check, gather evidence that discriminates between them, isolate the true cause, implement and validate a fix, and decide whether the incident needs a rollback, an escalation, or a written postmortem. The loop repeats: each piece of evidence should narrow the hypothesis set, not just confirm what you already believed.
Structured elaboration
- Observe the symptom precisely. Write down exactly what is wrong, in falsifiable terms: not "the API is slow" but "p99 latency (the response time slower than 99% of requests, i.e. how bad the worst cases are, not just the average) on
POST /ordersrose from 80ms to 900ms starting at 14:32 UTC, affecting roughly 3% of requests." Vague symptoms produce vague hypotheses. - Form hypotheses before you start digging. List the plausible causes given what changed recently (deploys, config, traffic pattern, dependency versions) and what the symptom rules out. A hypothesis you cannot state is a hypothesis you cannot test.
- Prioritize by expected information gain divided by cost. A five-minute log grep that could confirm or kill three hypotheses at once beats a one-hour deep profiling session that only speaks to one.
- Gather evidence that discriminates. Logs tell you what happened at a point; metrics tell you the shape of the problem over time; traces tell you where time went inside one request. Pick the instrument that actually distinguishes your live hypotheses, not the one you're most comfortable with.
- Isolate the root cause, not just a correlated symptom. A dropped hypothesis should be dropped because evidence contradicts it, not because you got bored of it.
- Implement and validate the fix against the same evidence that revealed the problem. If you diagnosed via a specific metric, watch that metric recover before declaring victory.
- Decide what happens next. If customer impact is ongoing and the fix is unproven, roll back first and diagnose second. If a similar failure could recur, or the incident had real impact, write it up so the org doesn't relearn the same lesson.
Worked example
A "the checkout page is slow" report, applied through the loop: symptom precisely stated as "median load time is normal, but a subset of loads takes 8-12 seconds, starting after this morning's deploy." Hypotheses: (a) the new deploy added a blocking call, (b) a downstream dependency degraded independently, (c) the slow subset shares a common attribute (e.g., a specific region or a large cart). A single log query grouping slow requests by attribute would discriminate between (c) and the other two in minutes, before touching a profiler. Suppose it shows the slow requests all hit a newly added inventory-check call to a dependency with no timeout: that both confirms (a) and rules out (b)/(c) as primary causes. Fix: add a timeout and a fallback; validate by watching the p99 metric drop back to baseline over the next hour, not just the fix compiling.
Trade-offs and pitfalls
The biggest failure mode is skipping hypothesis formation and going straight to your favorite tool (attaching a profiler because you're comfortable with it, even when a five-minute log check would have ruled out two hypotheses first). The second is treating the first correlated signal as the cause without checking whether it's actually causal. Under time pressure it's tempting to fix the first plausible thing you see; that's fine as a mitigation, but the loop isn't complete until you've confirmed the metric recovered and understood why, or you will be back debugging the same symptom next week.
What techniques do you use to prioritize multiple concurrent bugs or incidents affecting ML systems? Describe a decision rubric considering severity, user impact, reproducibility, rollback cost, and business KPIs, and explain how you would apply it during a busy incident window.
Sample Answer
Direct answer
Prioritize concurrent bugs and incidents using an explicit rubric weighing severity, user impact, reproducibility, rollback cost, and business KPIs together, not any single factor alone, since a high-severity-sounding bug with low actual user impact and an expensive rollback can rank BELOW a "smaller" bug that's actively costing revenue and has a trivial fix available.
Structured elaboration
The rubric, and how each factor is weighed:
- Severity: how bad is the failure mode itself (data loss/corruption ranks above a cosmetic issue, a security-relevant bug ranks above a performance blip), independent of how many users are currently affected.
- User impact: how many users/requests are affected right now, and is that number growing, stable, or shrinking; a severe bug affecting a handful of users may rank below a moderate bug affecting a large fraction of traffic.
- Reproducibility: a reliably reproducible bug can be diagnosed and fixed faster (lower time-to-resolution for the same engineering effort) than an intermittent one, which affects how quickly EACH candidate bug can actually be resolved if picked next, not just how bad it is.
- Rollback cost: if a bug traces to a specific recent change, how cheap and safe is reverting that change right now; a bug with a trivial, low-risk rollback available should often be handled immediately regardless of its rank on other factors, since the fix is nearly free.
- Business KPIs: which specific business metric is being affected (revenue, a contractual SLA, a compliance requirement) and how directly; a bug affecting a metric with hard, immediate business consequences (a broken payment flow) generally outranks one affecting a softer, longer-horizon metric even at similar technical severity.
Applying the rubric during a busy incident window: first, quickly triage EVERY open issue against the rubric (a few minutes per issue, not a deep investigation), to get a relative ranking rather than working issues in the order they arrived; second, look specifically for any issue with BOTH meaningful impact AND a cheap available mitigation (like a trivial rollback), since these should jump the queue regardless of their raw severity ranking, because the cost of addressing them is so low relative to the benefit; third, re-triage periodically as the window continues, since impact and severity can both change (a bug's blast radius growing, or a rollback becoming available partway through investigation of one issue), rather than treating the initial ranking as fixed for the whole incident window.
Worked example
Three concurrent issues during a busy window: (A) a high-severity-sounding data-consistency bug affecting a small, specific edge case (low current user impact, no clear quick fix, moderate rollback risk since the change is tangled with other recent work); (B) a moderate-severity bug causing a checkout-flow error for roughly 5% of transactions (clear, growing user impact, directly hitting a revenue KPI, and traced quickly to a specific recent config change with a trivial, low-risk rollback available); (C) a low-severity cosmetic UI bug reported by a few users (minimal impact, no urgency). Applying the rubric: (B) is prioritized FIRST despite being technically "less severe" than (A) in the abstract, specifically because it combines real, growing, revenue-affecting impact with an almost-free rollback fix, making it both the highest-leverage and fastest issue to resolve. (A) is prioritized second, staffed for a proper investigation given its rollback isn't cheap and its actual mechanism needs to be understood before a safe fix can be applied. (C) is deprioritized entirely for the duration of the busy window, revisited once the window calms down.
Trade-offs and pitfalls
A common mistake is prioritizing purely by SEVERITY LABEL (treating "critical" as automatically first regardless of current impact or fix cost), which can leave a rapidly-growing, revenue-affecting, cheaply-fixable issue waiting behind a technically-severe-but-currently-narrow, expensive-to-fix one; the rubric's explicit multi-factor weighing exists specifically to avoid that trap, and re-triaging periodically (rather than committing to the initial ranking for the whole window) accounts for the fact that these factors genuinely change as an incident window progresses.
Write a short script, or describe in Bash commands, how you would extract and correlate log lines that share a request-id across three services' log files for a single one-minute window. Mention scaling considerations for large log volumes.
Sample Answer
Direct answer
Grep each service's log file for the shared request_id, merge the results, and sort by timestamp, since the request_id is what ties otherwise-independent log lines across services into one causal sequence. A short, reusable script wraps this into a single command rather than three manual greps and a mental merge.
Structured elaboration
#!/bin/bash
# correlate.sh <request_id> <log_dir>
set -euo pipefail
request_id="$1"
log_dir="$2"
# Pre-filter with a fast fixed-string grep, then require request_id= to match
# as an EXACT whitespace-delimited token, so a shorter id like "req-1" can never
# match a longer one like "req-10" as a substring.
grep -h -F "request_id=${request_id}" "${log_dir}"/*.log \
| awk -v rid="request_id=${request_id}" '{
for (i = 1; i <= NF; i++) { if ($i == rid) { print; next } }
}' \
| sort
The grep -F pass is a fast pre-filter; the awk pass then requires request_id=<id> to match one whitespace-delimited token EXACTLY rather than as a substring, since a plain grep "request_id=${request_id}" would incorrectly also return rows for request_id=req-10 when searching for req-1 (and could also mismatch on any regex metacharacter that happened to appear in a request_id). sort on ISO-8601 timestamps (which sort correctly as plain strings, since the format is lexicographically ordered) then produces a single chronological view across all three services without needing to know which log came from which service ahead of time.
Worked example
Sample logs for three services, each with an entry for the same request_id:
service-a.log: 2025-06-01T10:00:00Z INFO request_id=req-1 msg="received request"
service-b.log: 2025-06-01T10:00:01Z INFO request_id=req-1 msg="forwarded to backend"
service-c.log: 2025-06-01T10:00:02Z INFO request_id=req-1 msg="processed successfully"
Executed: ./correlate.sh req-1 logs
2025-06-01T10:00:00Z INFO request_id=req-1 msg="received request"
2025-06-01T10:00:01Z INFO request_id=req-1 msg="forwarded to backend"
2025-06-01T10:00:02Z INFO request_id=req-1 msg="processed successfully"
A second request that fails midway (req-2), run the same way, correctly isolates just that request's cross-service trail:
2025-06-01T10:00:05Z INFO request_id=req-2 msg="received request"
2025-06-01T10:00:06Z ERROR request_id=req-2 msg="timeout calling downstream"
confirming the timeline: service A received the request, forwarded it to service B, and service B reported a timeout one second later, exactly the sequence needed to know which hop failed.
Scaling considerations for large log volumes
- Plain
grepacross large files is I/O-bound, not CPU-bound; for logs beyond a few GB per service, preferripgrep(rg, which is substantially faster on large files due to better I/O and regex engine choices) or push log correlation into a proper log-aggregation system (Elasticsearch/OpenSearch, Loki, Splunk) where the request_id becomes an indexed field and lookups are near-instant regardless of total volume. - Log rotation means a single request's trail can span multiple rotated files (
app.log,app.log.1,app.log.2.gz); the script would need to glob across rotated files and handle gzipped ones (zgrepinstead ofgrepfor.gzfiles) to stay correct once rotation is in play. - Clock skew across hosts can make timestamp-sorted output subtly wrong at sub-second granularity; for services on different hosts, prefer a monotonic sequence number or a trace-span ordering over raw wall-clock timestamps when precise ordering matters, and treat wall-clock timestamps as approximate once multiple hosts are involved.
Trade-offs and pitfalls
A one-off grep-and-sort script is the right tool for an ad hoc investigation into a handful of requests; it does not scale to "which requests failed across the fleet in the last hour," which needs the aggregation-system approach instead. Reaching for the heavier tool too early wastes setup time on an investigation that a two-line grep would have resolved in under a minute; reaching for grep too late (on a fleet-wide investigation) wastes far more time waiting on slow, unindexed scans across many hosts.
Tell the story of a concrete bug or production failure you found. Explain how you detected it, how you reproduced it if that was possible, the debugging tools and techniques you used, the root cause, and the permanent fix you implemented.
Sample Answer
Direct answer
A concrete story: a service occasionally returned stale pricing data to a subset of users, detected via a customer complaint rather than any internal alert (since the values were plausible-looking, just wrong, not obviously broken); the root cause traced to a caching layer that keyed its cache entries incorrectly, causing two logically-distinct pricing contexts to collide and overwrite each other's cached value, and the permanent fix corrected the cache key's uniqueness rather than just adjusting the cache's expiry time.
Structured elaboration
How it was detected: a customer support ticket reported seeing a price that didn't match what should have applied to their account tier, with no corresponding error or alert on the engineering side, since the returned value was a real, validly-formatted price, just the WRONG one; this is a useful detail because it illustrates a class of bug (returning plausible-but-wrong data) that's structurally invisible to error-rate-based monitoring, and only surfaces via a downstream consumer noticing a substantive discrepancy.
How it was reproduced: confirming the report wasn't a one-off required identifying the PATTERN, not just the single instance; checking whether other users on the same account tier around the same time window also received an unexpected price showed a small but real cluster, ruling out "one weird one-off" and confirming a systemic, reproducible mechanism worth a full investigation.
Debugging tools and techniques used: traced the pricing-lookup code path for the affected requests, and found it flows through an in-memory cache keyed, it turned out, on account tier ALONE rather than on the combination of account tier AND region (pricing legitimately varies by both); when two users on the same tier but different regions made requests close together in time, the second request's result could overwrite the first's cache entry under the shared, insufficiently-specific key, and a THIRD user (same tier, either region) arriving shortly after could then receive whichever region's price happened to be cached most recently, regardless of their own actual region.
The root cause: a cache key that didn't include every dimension the underlying value actually varied by, a classic caching-correctness bug: the cache was implicitly promising "this value is valid for anyone with this tier," when the real invariant needed was "this value is valid for anyone with this tier AND this region."
The permanent fix implemented: updated the cache key to include region alongside tier, restoring the correct invariant; also added a specific integration test that exercises exactly this scenario (two regions, same tier, interleaved requests) to catch a regression of this specific mechanism in the future, since the original bug had shipped without any test covering this particular combination of dimensions.
What you learned that helps you avoid similar bugs: whenever introducing a cache, explicitly enumerate every dimension the cached value can legitimately vary by, and verify the cache key includes ALL of them, not just the ones that happen to be obvious or top-of-mind at implementation time; a caching bug of this shape is especially dangerous specifically because it fails SILENTLY (no error, no crash, just occasionally-wrong data) and is invisible to typical error-rate monitoring, which argues for treating "does this cache key capture every dimension of variation" as a deliberate design-review question on any future caching work, not something to verify only after a bug report arrives.
Trade-offs and pitfalls
The tempting quick fix, once the symptom (stale/wrong cached price) was understood, would have been to simply reduce the cache's TTL (expiry time), which would have reduced the WINDOW during which a collision could produce visibly wrong data without fixing the actual collision mechanism at all; the permanent fix specifically addressed the cache KEY's correctness, not the expiry duration, since a shorter TTL would have masked the bug's visible frequency without removing its root cause.
Unlock Full Question Bank
Get access to all 33 Debugging and Systematic Troubleshooting interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.