API and Integration Troubleshooting Questions
Diagnosing failures across API and integration boundaries: reading status codes and error payloads, tracing requests across services, latency and timeout investigation, TLS/CORS/auth failures, and pinpointing whether a fault is client, network, gateway, or provider. Covers logging/observability for integrations and systematic debugging of intermittent sync and connectivity issues.
A third-party payments API intermittently fails (~0.5% of transactions), impacting customer checkout. Provide a structured remediation plan that balances short-term mitigations (retries, fallbacks) with long-term fixes (alternative providers, SLA negotiation). Include monitoring, rollback strategies, customer communication templates, and decision criteria for switching providers.
Sample Answer
Scope & goals:
- Restore checkout reliability quickly, protect revenue, preserve UX while designing durable fixes and contractual protections.
Immediate (hours) — short-term mitigations
- Circuit breaker + rate limiter: stop calling provider when error spike > threshold (e.g., 1% failure over 5m).
- Retry with idempotency and exponential backoff (max 2 retries, jitter). Ensure transactions are idempotent to avoid double-charges.
- Fallback: route eligible traffic to fallback path (local tokenization / queued offline processing / alternate provider) for low-risk payments.
- Feature-flag deployment for toggling retries/fallbacks quickly.
Example retry pseudocode:
# idempotent retry with exponential backoff
def call_payment(payload, idempotency_key):
for attempt in range(3):
resp = provider.charge(payload, idempotency_key)
if resp.success: return resp
if not transient_error(resp): break
sleep((2**attempt) * 0.2 + random_jitter())
raise PaymentError(resp)
Medium-term (days–weeks)
- Root-cause analysis: collect request traces, provider logs, HTTP codes, latency, geographic patterns, and payload shapes.
- Harden integration: strict validation, timeout tuning, improved error classification (4xx vs 5xx vs network).
- Automated canaries & synthetic transactions exercising edge cases.
Long-term (weeks–quarters)
- Multi-provider architecture: abstract payment gateway with strategy pattern, dynamic routing, reconciliation, and per-provider feature matrix.
- SLA negotiation & penalties: demand SLOs (availability, P95 latency), credits, and response-time commitments. Add audit/logging access.
- Business continuity: documented runbooks, regular failover tests, and contractual exit clauses.
Monitoring & alerting
- Metrics: success rate, error rate by code, latency percentiles, payment throughput, % of retries, fallback usage, reconciliation failures.
- Alerts: page on >0.5% failure sustained for 10m or >2% for 2m; escalation for reconciliation mismatches.
- Dashboards: real-time flows with drill-down by region, merchant, and payment type.
- Logs & traces: include idempotency key, provider request/response IDs, correlation IDs.
Rollback & incident playbook
- Trigger: detection of spike or failed canary.
- Actions: enable circuit breaker → route to fallback/alternate provider → disable nonessential features → notify stakeholders.
- Rollback: revert to previous stable integration code or switch routing to alternate provider via config flag; verify reconciliation.
- Post-incident: blameless postmortem with timeline, RCA, and action items (within 72h).
Customer communication templates
- Short outage alert (email/in-app):
“We’re aware of an intermittent payment issue affecting checkout for some customers. Our team is applying fixes now; most purchases should succeed with retries. If you experienced a failed charge, please check your bank — we’ll notify you if any duplicate charges are found. Estimated resolution: 2 hours.” - Follow-up/resolution:
“The payment issue has been resolved. If you experienced a failed transaction, you may retry or contact support (link). We will proactively refund or reconcile any duplicate charges. We apologize and appreciate your patience.”
Decision criteria for switching providers (quantitative + qualitative)
- Quantitative:
- Persistent availability < 99.5% over 30 days despite mitigations.
- Error rate after retries > 0.5% for key geos or payment types.
- Unacceptable MTTR: average incident resolution > 4 hours or > 3 incidents/month.
- Business impact: revenue loss or chargeback increase > predefined threshold.
- Qualitative:
- Poor transparency or lack of logs/traceability.
- Uncooperative support or missed SLA commitments.
- Incompatibility with required features (3DS, tokenization, fraud tools).
- Cost & onboarding complexity vs benefit.
If one or more thresholds met and contractual remediation fails, start procurement: RFP, parallel testing, data migration plan, and phased cutover with reconciliation.
Ownership & timeline
- Incident lead (on-call SE) for hours; payment product manager for vendor negotiations; engineering to deliver multi-provider abstraction in 4–8 weeks with canary rollouts and reconciliation automation.
This plan balances rapid containment and customer-facing mitigations with engineering investments and contractual risk control to avoid recurring outages.
A customer reports that your JavaScript SDK throws an obscure exception when calling sdk.createResource with valid input. Walk through a reproducible triage plan: what logs and telemetry to collect, how to reproduce in a sandbox, what SDK version and environment metadata to record, how to instrument the SDK to surface useful stack traces and version info, and how to communicate the fix and timeline to affected developers.
Sample Answer
Situation: A customer reports an obscure exception from sdk.createResource with valid input.
Triage plan (steps):
- Collect immediate telemetry
- Ask customer for: exact error message, full stack trace, timestamp (UTC), sample request payload, network request/response (headers, status, body), console logs, browser/Node version, OS, SDK version, and any bundler/transpiler (Webpack/Babel) info.
- Check server-side logs (if applicable): correlation-id, request-id.
- Reproduce in sandbox
- Create minimal reproducible repo (vanilla HTML+JS or Node script) using the same SDK version and identical payload.
- Run in both environments reported (same browser, incognito, and latest stable).
- Toggle feature flags and config to match customer.
- Record environment & version metadata
- SDK semantic version, commit SHA, build date, minified vs dev build.
- Runtime: browser userAgent or Node version, OS, package manager lockfile (package-lock/yarn.lock).
- Transpilation details: target, polyfills.
- Instrument SDK
- Ensure SDK emits structured telemetry: SDK.version, commit SHA, platform, env (prod/dev), and call-site metadata.
- Wrap createResource to capture and rethrow enriched errors with context (payload hash, request-id).
- Add source-maps for minified builds and ensure stack traces map to original sources.
- Add try/catch that logs full Error.stack and JSON.stringify(context) to telemetry sink (Sentry/Datadog) with user-visible correlation-id.
- Debug & fix
- Use reproducible case to step through with debugger; inspect network and serialized data.
- If root cause is a serialization/edge-case bug, add input validation and clearer error messages.
- Communicate to customers/devs
- Acknowledge receipt within 1 business hour with requested info checklist and temporary mitigation (e.g., input change or SDK rollback).
- Provide ETA for root-cause analysis (24–48 hrs) and fix release timeline (patch in next sprint or hotfix same day if critical).
- Share interim status updates and final release notes: changelog, migration steps, and reproducible test case.
- After release, follow up with the customer to confirm resolution and ask permission to close the ticket.
This approach prioritizes reproducibility, enriched telemetry, clear versioning, and timely customer communication.
Given a REST endpoint suffering from high tail latency, list and evaluate optimizations: caching, connection reuse, parallelizing backend calls, circuit breakers, asynchronous responses, HTTP/2, payload compression, and database query tuning. Explain trade-offs, measurement points, and how you'd prioritize fixes.
Sample Answer
Start by measuring: collect P50/P95/P99 latencies, tail latency heatmap, request traces (distributed tracing), CPU/memory/Goroutine/thread counts, GC, socket counts, DB query times, and error/retry rates. Only with data can you prioritize.
Evaluate optimizations (what they do, when effective, trade-offs, signals to watch):
-
Caching (edge, CDN, app-level, DB result cache)
- Benefit: cuts downstream calls => large, immediate P95/P99 reduction for cacheable responses.
- Trade-offs: staleness, cache invalidation complexity, memory cost.
- Measure: cache hit rate, latency delta on cache vs miss, consistency requirements.
-
Connection reuse (keepalives/pooling)
- Benefit: avoids TCP/TLS handshake and connection setup jitter; reduces tail from many short calls.
- Trade-offs: pool sizing, resource exhaustion if misconfigured.
- Measure: connection churn, SYN/retry rates, per-request connect time.
-
Parallelizing backend calls (fan-out)
- Benefit: reduces critical-path time when service composes independent calls.
- Trade-offs: increased load on downstream services, complexity, coordination (first-success vs join).
- Measure: downstream QPS increase, amplified error/latency propagation.
-
Circuit breakers
- Benefit: prevent cascading failures and cap tail latency by failing fast.
- Trade-offs: potential increased user-visible errors; tuning thresholds matters.
- Measure: circuit-open events, fallback success rate, reduced waiting threads.
-
Asynchronous responses (deferred, polling, webhooks)
- Benefit: moves work off critical path, great for long-running ops.
- Trade-offs: UX changes, increased system complexity, retry/in-order guarantees.
- Measure: request acceptance latency vs completion latency, backlog lengths.
-
HTTP/2
- Benefit: multiplexing reduces head-of-line blocking and expensive connection setup for many small requests.
- Trade-offs: server/proxy compatibility, complexity with middleboxes, potential single-connection saturation.
- Measure: per-stream latency, number of connections per client, TLS handshake reduction.
-
Payload compression
- Benefit: reduces transfer time for large payloads; helps high-latency networks.
- Trade-offs: CPU cost for compression/decompression; not useful for small JSONs.
- Measure: bytes transferred, CPU usage, end-to-end transfer time.
-
Database query tuning
- Benefit: eliminates slow tail from bad queries—often highest ROI for dynamic data paths.
- Trade-offs: schema/index changes, maintenance, potential write amplification.
- Measure: slow query log, P99 query time, index hit ratios, lock/IO waits.
Prioritization framework:
- Instrumentation & baseline (tracing, metrics) — required first.
- Quick wins with low risk: caching hot responses, connection reuse, payload compression for large responses.
- Medium work: DB tuning (profile queries), enable HTTP/2 where safe.
- Higher effort/impact: parallelization with throttling, async patterns, circuit breakers with sensible fallbacks.
- Validate with canary/A-B and load tests; monitor P99 while rolling.
Final note: always measure before/after (P50/P95/P99, errors, CPU), and avoid optimistic fixes that move latency elsewhere (e.g., fan-out without throttling).
Describe an observability strategy focused on developer experience for an API product. Specify the traces, metrics, and logs you would collect to help developers troubleshoot integration failures, what correlation ids and sampling rules to use, how to surface actionable traces to external developers, and how to avoid leaking sensitive information in shared telemetry.
Sample Answer
Approach summary: design observability as a developer-first experience: make failures easy to reproduce and reason about while protecting customer data. Use OpenTelemetry for traces, Prometheus metrics, and structured JSON logs shipped to a centralized back end (e.g., Tempo/Jaeger + Loki/ELK + Prometheus/Grafana).
Traces (what to capture)
- Per-request root span with protocol info (HTTP/gRPC), endpoint, method, status code, latency.
- Downstream spans for auth, DB, cache, third-party API calls including endpoint, latency, and errors.
- Annotate spans with non-sensitive context: service.version, deployment.env, integration_type, sanitized_error_code.
- Capture request-id/trace-id and sampled request/response size but never raw PII.
Metrics (developer-focused)
- Request rate: api.requests.count{endpoint, method, env}
- Error rate: api.errors.count{endpoint,status_family,integration}
- Latency histograms: api.latency_ms_bucket{endpoint}
- Integration-specific success/failure ratios and retry counts
- SLO/SLA indicators: availability, p95/p99 latency
Logs (structured fields)
- timestamp, trace_id, span_id, request_id, service, env, endpoint, status, error_code, sanitized_user_id_hash
- Include small, structured contextual messages; avoid full request bodies in normal logs.
Correlation IDs & propagation
- Accept and propagate standard headers: traceparent (W3C), x-request-id, x-api-client-id.
- If client provides request-id, use it as top-level request_id and map to trace_id.
- Generate request-id when absent and return it in response headers to help external devs correlate.
Sampling rules
- Always-sample: all errors (status 5xx, auth failures), requests hitting SLO thresholds (latency > p99), and any trace explicitly requested via request_id.
- Probabilistic sampling: sample ~1–5% of successful traces per endpoint.
- Tail-based sampling: keep traces that show unusual patterns (multiple retries, long tail latencies).
- Allow dynamic sampling overrides via a sampling service for on-demand increased capture during incidents.
Surfacing actionable traces to external developers
- Expose a "Troubleshoot" endpoint in the developer portal where users paste their request-id; backend looks up sanitized trace and shows:
- Timeline of spans with durations and error annotations
- Human-readable failure cause and suggested remediation (e.g., "invalid signature", "rate limit exceeded")
- Example curl/request reconstructed with sensitive fields redacted
- Link to SLO and recent related traces
- Provide SDK helpers that return request_id in SDK responses and helper to auto-open a dev-portal trace viewer.
Avoid leaking sensitive information
- Redact or hash sensitive fields at capture boundary:
- Replace emails, SSNs, tokens with deterministic hashes (sha256(salt+value)) and store the salt only in secure vault if reversible matching is needed.
- Truncate or exclude request/response bodies by default; allow opt-in developer payload capture with explicit consent and per-tenant retention policy.
- Apply server-side PII scrubbing processors (regex + schema-based) before logs/spans leave the service.
- Enforce RBAC and field-level encryption in telemetry stores; audit access.
- Set short retention for high-risk fields and keep full payloads only in ephemeral stores for debugging windows.
- Document what is and isn't captured clearly in the developer docs.
Why this helps developers
- Request-id + accessible traces let third-party devs and internal engineers find the exact execution path quickly.
- Error-first sampling ensures actionable failures are always available.
- Structured metrics and SLO dashboards help developers prioritize fixes.
- Sanitization and opt-in capture balance debugging depth with privacy/compliance.
Implementation notes
- Use OpenTelemetry SDK to instrument and auto-propagate trace headers.
- Implement a middleware layer that enforces redaction and attaches standardized attributes.
- Provide CLI/SDK tooling to look up traces by request-id and to request temporary full captures during agreed incident windows.
You see intermittent 403 forbidden responses from a third-party API used for ad delivery during peak hours. Provide a diagnostic checklist to identify root causes and propose temporary mitigations to reduce customer impact while you investigate. Include authentication, rate limit, and vendor-side checks.
Sample Answer
Diagnostic checklist — quick steps to triage intermittent 403s
- Reproduce & scope
- Confirm frequency/timestamps, regions, user segments, ad zones. Correlate with load/peak-hour windows.
- Verify whether 403s come from specific endpoints, client tokens, or IP ranges.
- Authentication checks
- Check client credentials used (API key, OAuth token): expiry, rotation events, clock skew for JWTs.
- Inspect request headers in logs for Authorization, API-Key, or x-client-id mismatches.
- Validate token issuance logs (auth server) and recent deployments that might change header format.
- Rate-limit / quota checks
- Review third-party rate-limit headers (X-RateLimit-*, Retry-After) and our request rate during peaks.
- Query metrics for 429 vs 403; sometimes vendor returns 403 when quota exceeded or invalid plan.
- Check per-API-key and per-IP usage and sudden spikes (bursts from a worker/job).
- Vendor-side and contract checks
- Check vendor status pages, incident notices, and API change logs for recent policy changes (geo-blocking, content rules).
- Confirm account standing (billing, plan limits, TOS enforcement) with vendor support.
- Verify whether vendor is rate-limiting or blocking specific creatives/ads (content moderation).
- Network & infra checks
- Inspect WAF, CDN, or reverse-proxy rules for false positives blocking requests during peak traffic.
- Confirm IP allowlists/deny rules and outbound NAT IP churn that might trigger vendor blocks.
- Check TLS negotiation errors that might surface as 403 in vendor logs.
- Application & code checks
- Audit recent deploys that touch auth header construction, retry logic, or header sanitization.
- Ensure no malformed URLs/headers or incorrect content-type that vendor rejects.
- Logs & telemetry
- Correlate app logs, vendor response body, and vendor request-id headers for specific failures.
- Capture full request/response (sanitized) for sample 403 events and forward to vendor for investigation.
Temporary mitigations to reduce customer impact
- Short-term fallbacks
- Implement a circuit breaker for the failing vendor endpoint with fast failover to a secondary provider or cached creatives.
- Serve cached ads or lower-risk default creatives for affected zones during the outage window.
- Throttling & retry strategy
- Add adaptive client-side throttling: detect spikes and smooth requests (token bucket) to avoid bursts that trigger blocks.
- Implement exponential backoff with jitter and honor Retry-After. Cap retries to avoid escalating failures.
- Auth resilience
- Pre-warm and refresh tokens before peak hours; add graceful fallback when token refresh fails (use a read-only cached token until recovered).
- Temporarily route requests through a stable set of NAT IPs if vendor blocks by IP.
- Visibility & communication
- Add temporary monitoring/alerting for 403 rate and notify SRE/PM/vendor on-call.
- Communicate an incident status to stakeholders/customers and provide ETA and workaround guidance.
When escalating to vendor
- Provide sanitized request/response examples including timestamps, request-id headers, client IPs, tokens (masked), and traffic patterns.
- Ask vendor to confirm whether 403 is due to auth, quota, content policy, or WAF on their side and request logs correlating their decision.
Why this approach
- Systematic isolation (auth vs rate vs vendor policy vs infra) narrows root cause quickly.
- Temporary mitigations reduce user impact without masking the underlying issue; they also provide time for vendor coordination and a safe rollback if a deploy introduced the problem.
Unlock Full Question Bank
Get access to all 6 API and Integration Troubleshooting interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.