Forward Deployed EngineeringSoftware EngineeringProduction Debugging
A customer's app calling your API times out intermittently. You can't see their code. Debug it.
Question 30 of 73 · Updated
On this page
- Interview-ready answer
- 1. Establish the incident scope
- 2. Find the failure boundary
- 3. Understand the timeout types
- 4. Correlation IDs and distributed tracing
- 5. Compare failed and successful cohorts
- 6. Reproduce without customer source code
- 7. Timeouts, deadlines and retries
- 8. Tested Python: bounded deadline-aware retries
- 9. Practical incident example
- 10. Mitigation versus root-cause resolution
- 11. Customer communication and verification
- 12. Production engineering takeaways
- Likely interviewer follow-ups
Interview-ready answer#
I would treat this as an end-to-end incident, not immediately assume that either the customer or our API is at fault. First, I would establish the impact, the exact timeout behavior and a small set of successful and failed requests. I would ask the customer for UTC timestamps, the endpoint, client timeout settings if available, request or correlation IDs, the exact exception or HTTP status, and redacted request characteristics. I do not need their application source code to begin.
Next, I would correlate those examples against our edge, gateway, application and dependency telemetry. The first important distinction is whether the request reached our infrastructure. If it did, I would locate the slow stage or missing response using distributed traces and logs. If it did not, I would investigate DNS, connectivity, TLS, proxies and client-side connection or pool delays with the customer's cooperation. A missing log alone is not proof that a request never arrived.
I would compare failing and successful cohorts, reproduce the issue with a minimal authorized client from a comparable environment, and test one hypothesis at a time. I would mitigate the immediate impact while avoiding blind timeout increases or retry storms. Finally, I would validate the fix under representative traffic, confirm it with the customer and document both the root cause and prevention measures.
1. Establish the incident scope#
The word "timeout" is not a diagnosis. It can describe a client-side exception, an HTTP error generated by a gateway, a service deadline, a stalled stream or an operation that never finishes.
Ask for a few failed and successful examples from the same customer workflow:
| Evidence | Why it helps |
|---|---|
| Timestamp in UTC and approximate duration | Aligns client observations with server-side telemetry |
| Request ID or trace ID | Locates a particular attempt |
| Endpoint, method and region | Narrows the route and infrastructure path |
| Exact exception and status code, if any | Distinguishes connection, read, gateway and application failures |
| Timeout and retry configuration | Reveals mismatched deadlines and repeated work |
| Payload size and request type | Tests whether failures correlate with expensive inputs |
| Traffic rate and concurrency | Reveals overload, pool exhaustion or burst-related behavior |
| SDK/runtime version and proxy or network environment | Identifies differences between a minimal reproducer and production |
Request only what is necessary. Ask for redacted logs, sanitized request shapes and approved diagnostic outputs through a secure channel. Never ask a customer to paste API keys, passwords, full authorization headers, sensitive payloads or unredacted packet captures into an ordinary support conversation.
Determine whether this is a new regression, whether other customers are affected, and whether a particular region, route, version or tenant is disproportionately impacted. Establish a severity and incident owner. If the customer cannot provide all fields immediately, start with the available timestamps and telemetry.
2. Find the failure boundary#
An apparent absence of a request may be caused by sampling, log loss, a different region, incorrect IDs, clock skew, retention gaps or incorrect query filters. Check the telemetry coverage before assigning responsibility.
A recorded successful response on the server is also not conclusive evidence that the client received the complete response. The gateway may have accepted bytes from the application without delivering them to the client. A stream may have sent headers and then stalled.
3. Understand the timeout types#
| Timeout or error | Typical boundary | What to check |
|---|---|---|
| DNS resolution delay | Name lookup | Resolver latency, failures, cached results, IPv4/IPv6 behavior |
| Connection timeout | Establishing transport | Routes, firewalls, connection limits, TCP handshake |
| TLS handshake failure or timeout | Securing transport | Certificates, SNI, inspection proxies, protocol compatibility |
| Pool-acquisition timeout | Waiting for an available local connection | Pool size, leaked responses, outstanding requests, concurrency |
| Read or idle timeout | Waiting for response bytes | Slow upstream, idle proxy limits, stalled stream |
| Overall deadline | Total logical request duration | Queueing, attempts, backoff, dependency budgets |
| HTTP 504 | Gateway waiting for an upstream response | Gateway and upstream timing and error logs |
| HTTP 408 | Server timed out waiting for a complete request | Request upload, slow sender or proxy behavior |
| Connection reset | Transport interrupted | Peer/proxy resets, connection reuse, network and server lifecycle |
These names and behaviors vary by HTTP client, proxy and deployment. For example, a read timeout is often an inactivity timeout rather than an overall request deadline. Some gateways use implementation-specific status codes for a disconnected client. Inspect the actual product configuration and error details instead of assuming identical semantics.
4. Correlation IDs and distributed tracing#
Use two levels of identity when retries are possible:
- A logical operation ID identifies the customer action across attempts.
- A request or attempt ID identifies an individual HTTP attempt.
A distributed trace contains spans describing work across participating services. A W3C Trace Context traceparent header carries a trace identifier and parent-span information so downstream services can link the work. Preserve trace context through gateways, background work and downstream calls where appropriate. Use server-generated or validated identifiers and avoid trusting trace headers as identity or authorization.
Record UTC timestamps for cross-system correlation and monotonic elapsed durations for local latency measurement. Correlation is easier when clocks are synchronized, but elapsed-time budgets should not depend on wall-clock adjustments.
Useful telemetry includes route, status, region, deployment version, request size class, gateway time, queue wait, application duration, database wait, dependency duration, retry count and cancellation state. Avoid logging sensitive data and uncontrolled high-cardinality metric labels.
A trace should answer which stage waited, why it waited, whether the request was cancelled and whether its business effect committed. Inspect successful and failed examples, not only the slowest trace.
If the client has already timed out, the server may continue processing. A timeout therefore does not prove that a write failed. Use cancellation where supported and retain authoritative operation status and idempotency protections.
5. Compare failed and successful cohorts#
Compare latency distributions, errors and throughput for the same endpoint and time window. Break down by bounded, meaningful dimensions:
| Pattern | Hypothesis to investigate |
|---|---|
| Failures near exactly 30 or 60 seconds | Configured deadline or idle timeout |
| First request slow after an idle interval | DNS/TLS setup, stale pooled connection or cold start |
| Failure increases with concurrency | Pool exhaustion, queueing, worker or downstream saturation |
| Only large payloads fail | Upload time, size limits, parsing or processing cost |
| Only a region or network fails | DNS, routing, proxy, regional availability or latency |
| Failure starts after rollout | Code/configuration regression, new dependency behavior |
| Only one tenant fails | Data shape, hot partition, tenant quota or tenant-specific integration |
These are hypotheses, not proof. Compare at similar offered load, request type and software versions. For example, an exact 30-second failure pattern suggests a deadline, but does not identify which layer owns that deadline.
6. Reproduce without customer source code#
Ask the customer to run a minimal, authorized request from the same runtime or network where practical. Use a non-mutating test endpoint or a sandbox and sanitized inputs. Compare a fresh connection with connection reuse, small versus large inputs, sequential versus bounded concurrent requests, and the customer's normal route versus an approved alternative network.
A simple curl diagnostic for an authorized read-only health endpoint can reveal major timing boundaries:
BASHcurl --silent --show-error --output /dev/null \ --connect-timeout 3 --max-time 10 \ --write-out 'status=%{http_code} dns=%{time_namelookup} connect=%{time_connect} tls=%{time_appconnect} ttfb=%{time_starttransfer} total=%{time_total}\n' \ https://api.example.com/health
This is an illustrative command using a placeholder host, not a command executed against a customer or production service. Substitute an authorized endpoint and handle authentication through an approved secret-management mechanism if required. The health endpoint may exercise a much cheaper path than the failing API, so a healthy result does not rule out an application-level failure.
The curl timing fields are cumulative elapsed times in seconds, not independent durations. For a simple new HTTPS connection, approximate TCP establishment time by subtracting DNS time from connect time, and TLS time by subtracting connect time from appconnect time. Connection reuse, proxies and redirects complicate these interpretations. Time to first byte includes preceding phases and server-side waiting; it is not pure server processing time.
Inspect customer resolver behavior and the destination addresses, TLS negotiation, approved firewall/proxy logs, and regional routing where relevant. Do not ask the customer to disable TLS verification, bypass enterprise security controls or expose confidential traffic. Collect low-level traces only with authorization and appropriate redaction.
A successful synthetic request from our office proves only that our tested path worked. It does not prove the customer's path is healthy. Run controlled comparisons that preserve the relevant environment and communicate what each experiment does and does not establish.
7. Timeouts, deadlines and retries#
A timeout limits a particular operation or waiting phase. A deadline specifies when the entire logical operation must finish. An overall deadline should include connection acquisition, network setup, queueing, processing, retries, backoff and response delivery.
Suppose a customer has a 3-second end-to-end budget. An illustrative allocation might reserve 300 ms for transport and edge overhead, 200 ms for queueing, 2 seconds for service and dependency work, and 500 ms for response delivery and uncertainty. These allocations are design targets, not observed timings. Real budgets must be determined with representative measurements.
Propagate the remaining budget through services and reserve enough time to return a response. A downstream timeout longer than the remaining client budget can waste resources. However, making a timeout arbitrarily short can reject legitimate work and cause additional retries.
Retry only when the failure is plausibly transient and the operation is safe to repeat. For an idempotent operation, use bounded attempts, exponential backoff with jitter, a shared retry budget and an overall deadline. Honor applicable Retry-After guidance within that deadline. Avoid retries at every layer: three attempts at each of three nested layers can lead to up to 27 downstream attempts for a single logical operation under worst-case independent retry behavior.
For writes, an HTTP timeout can occur after the effect commits. Use an idempotency key tied to a logical operation and immutable payload, or reconcile using an authoritative operation-status endpoint. Do not assume POST is safe to retry merely because the client did not receive a response.
For very long-running operations, consider an asynchronous job API that returns a job identifier and exposes status, cancellation and result retrieval. This changes the interface and user experience, so agree on the semantics with the customer. It does not eliminate the need for durability, authorization and duplicate-safe job creation.
8. Tested Python: bounded deadline-aware retries#
This dependency-free reference helper demonstrates one overall monotonic deadline and bounded retry behavior. The send callable must accept the remaining time budget and implement its own actual cancellation or timeout behavior. Only TimeoutError is classified as retryable in this deliberately small example, and only when the caller has established that retrying is safe.
PYTHONimport math import time def call_with_budget(send, *, budget, attempts=3, safe=False, clock=time.monotonic, sleep=time.sleep): if not math.isfinite(budget) or budget <= 0 or attempts < 1: raise ValueError('invalid retry policy') deadline = clock() + budget for i in range(attempts): remaining = deadline - clock() if remaining <= 0: raise TimeoutError('overall deadline exhausted') try: result = send(remaining) except TimeoutError: if not safe or i + 1 == attempts: raise delay = min(0.1 * 2**min(i, 5), deadline - clock()) if delay <= 0: raise sleep(delay) else: if clock() >= deadline: raise TimeoutError('response missed deadline') return result
Example of using the helper with a simulated sender:
PYTHON# This sender performs no network calls. def simulated_send(remaining): return {'status': 'ok', 'remaining_budget': remaining} result = call_with_budget(simulated_send, budget=2, safe=True) assert result['status'] == 'ok'
In a real HTTP client, connect, pool, read and write timeout settings may be independent rather than a strict overall deadline. Verify the client's actual semantics. A blocking transport that ignores cancellation may run beyond the budget: the helper rejects a late success but cannot forcibly stop a blocked send. Production code needs appropriate transport-level cancellation, jitter, explicit failure classification, resource cleanup and metrics. It also needs validated integer attempt counts and configuration. Keep the safe flag false for an operation whose repeatability has not been established.
Local verification: Python 3.13.5 executed the exact helper against 7,780 checks. Of these, 7,776 were deterministic scenarios varying four potential attempt outcomes (success, timeout, fatal failure), four total budgets, four attempt caps, safe versus unsafe retry behavior and three simulated per-attempt durations. An independent expected timeline checked terminal outcome, number of attempts, positive remaining budgets and elapsed time. Three invalid-policy checks and one noncompliant sender returning after the deadline also passed. Tests used an injected clock and synthetic send/sleep functions, not a live HTTP transport or distributed network. The curl snippet is illustrative.
9. Practical incident example#
Consider a fictional enterprise integration where a customer reports intermittent timeouts at approximately 30 seconds.
Initial findings might show that successful requests complete in under a second, while a subset of requests remains queued in our API waiting for database connections. Client logs indicate a 30-second overall deadline. Server traces for failed attempts show work continuing after the client disconnects.
That evidence supports a queueing or database-access hypothesis, but not necessarily a need for a larger database pool. I would inspect database saturation, query duration, connection checkout and return behavior, hot queries and concurrent work. Increasing pool size could worsen contention if the database is already saturated.
Suppose further controlled tests reveal that a recently deployed route holds connections during an unrelated downstream request. A possible remediation is to release the connection before the unrelated call, bound concurrency and propagate cancellation. I would test correctness of transaction boundaries before changing the code.
Validate the change using comparable traffic, request shapes and timeout settings. Check client-visible success, end-to-end p95/p99, connection wait, dependency load and abandoned work. Confirm the customer no longer sees the symptom in their actual workflow over an agreed observation period. Do not claim a fix from one successful probe.
This scenario is hypothetical, not an actual customer incident or measured result.
10. Mitigation versus root-cause resolution#
During an active incident, reducing impact can be more urgent than establishing the complete root cause.
| Mitigation | Important trade-off |
|---|---|
| Roll back a correlated deployment | Restore known behavior; ensure rollback is data/schema compatible |
| Limit concurrency or shed excess work | Protect dependencies but may reject or delay legitimate requests |
| Fix retry amplification | Reduce pressure; preserve appropriate recovery for transient failures |
| Temporarily adjust a documented timeout | May allow completion but increases outstanding work and resource occupancy |
| Route around a degraded region | Check consistency, authorization, data residency and available capacity |
| Switch long tasks to asynchronous processing | Requires explicit job lifecycle, duplicate protection and customer integration changes |
Use the smallest reversible mitigation supported by the evidence. Track its impact, owner, expiry and rollback criteria. Keep investigation and mitigation separate: a change that reduces symptoms is not necessarily proof of the underlying cause.
11. Customer communication and verification#
An FDE should coordinate the investigation without requiring the customer to reveal proprietary code. An initial update could say:
"We have confirmed the reported intermittent timeouts and are correlating the provided UTC timestamps and request identifiers against our gateway and application telemetry. Could you share the exact timeout exception, configured timeout duration and a redacted successful/failed request example? Please omit credentials and sensitive payloads. We will communicate verified findings, mitigation options and the evidence needed to confirm recovery."
Only say that an incident has been confirmed if the evidence supports that statement. Distinguish confirmed observations from hypotheses and unknowns. Agree with the customer on the next diagnostic step, communication cadence and criteria for recovery; avoid inventing an ETA or assigning blame before root cause is known.
After remediation, provide a concise incident summary: impact, timeline, confirmed cause, corrective action, remaining risk, monitoring and prevention. Verify customer-side results and server telemetry, not merely deployment success.
12. Production engineering takeaways#
Design APIs for debuggability before an incident. Return documented request identifiers, propagate trace context, instrument gateway and dependency boundaries, measure logical requests and attempts separately, and monitor timeout/cancellation outcomes in addition to latency distributions.
Evaluate capacity using offered load and outstanding work rather than assuming request rate alone describes saturation. Test timeouts, half-open connections, slow uploads, stalled streams, pool exhaustion, downstream errors, client disconnects and retry-after-commit behavior. Use representative load generation and avoid coordinated omission when modeling independent arrivals.
Enforce tenant-scoped access to support telemetry, redaction and retention. Restrict any production diagnostic action to authorized systems. When new instrumentation is needed, deploy it deliberately and avoid excessive logging or sensitive data exposure.
Likely interviewer follow-ups#
What if our application logs show nothing? Verify logging coverage and look at ingress, load balancer, DNS, proxy and transport evidence. Ask for a timestamp and request identifier from the customer. Absence of a sampled trace is not evidence of absence.
What if the server returned HTTP 200? Determine whether the gateway and client received the full response before their deadlines. A successful server log alone does not establish end-to-end delivery.
Would you increase the timeout? Only as a justified mitigation or contract adjustment after considering work duration, resource usage, customer expectations and downstream deadlines.
How do you debug without source code? Use the observable contract, redacted logs, correlation IDs, traces, controlled client probes and comparative experiments.
Should the customer retry a timed-out write? Only if the operation has a reliable repeatability guarantee or reconciliation mechanism. A timeout is an uncertain outcome, not proof of failure.
What makes this an FDE problem? The diagnosis spans customer environment, API boundaries, infrastructure and business semantics. The engineer must prove the failure mechanism, deliver a safe fix and confirm the customer's actual outcome.
References
- 1.
- 2.OpenTelemetry — Traces (not live-verified)opentelemetry.io
- 3.RFC 9110 — HTTP Semantics (not live-verified)rfc-editor.org
- 4.
- 5.
- 6.
- 7.Python time documentation (not live-verified)docs.python.org
Related questions
Explore other topics:AI AgentsAI System DesignLarge Language Models