An important third-party API your service depends on is down. How do you design and respond?
IntermediateScenarioReal-world scenarios
Answer
In one line: Respond by limiting the impact — fail gracefully, use fallbacks and communicate — and design ahead of time with timeouts, retries with backoff, circuit breakers, queues and caching so one external outage doesn't take your whole service down.
During the outage (respond):
- Confirm it's the dependency — your errors/latency point to calls to that API; check the provider's status page.
- Limit the blast radius:
- Make sure calls time out quickly, so your threads and connections aren't all stuck waiting.
- Turn off the dependent feature with a feature flag if the rest of the app can work without it.
- Use fallbacks — cached data, a default response, or "we'll email you confirmation shortly".
- Queue work to process later (for example queue order confirmations for the email service).
- Communicate — status page / customer support message if users are affected; contact the provider.
- Recover carefully — when it comes back, drain queued work at a controlled rate so you don't overload it.
Before the outage (design for it):
- Timeouts on every external call (never wait forever).
- Retries with exponential backoff and jitter — only for safe/idempotent operations; limit the number of retries so you don't make things worse.
- Circuit breaker — after many failures, stop calling the API for a short period and fail fast (libraries: Resilience4j, Polly, or a service mesh like Istio).
- Bulkheads — separate connection pools so one slow dependency can't use all resources.
- Asynchronous processing with queues (SQS, Kafka, RabbitMQ) for non-urgent work.
- Caching of responses where data can be slightly stale.
- Graceful degradation — decide in advance what the app should do without each dependency.
- Multiple providers for critical needs (for example two payment gateways or SMS providers).
- Monitoring and alerts per dependency — error rate and latency of outbound calls, plus synthetic checks.
Example: when the SMS provider went down, OTP login failed. The team added a circuit breaker, a second SMS provider as a fallback and an email OTP option. The next outage caused no customer-facing failure.
Tip for interviews: name timeouts, retries with backoff, circuit breakers and fallbacks — and say why retries without limits can make an outage worse.
More on Real-world scenarios
The website is slow. How do you troubleshoot it?IntermediateA deployment to production just failed halfway. What do you do?IntermediateDevelopers complain that the CI pipeline takes 40 minutes. How would you speed it up?IntermediateSomeone accidentally committed an AWS access key to a public GitHub repository. What do you do?IntermediateYour production disk is 95% full and the alert just fired. What do you do?IntermediateHow would you set up CI/CD for a brand-new microservice from scratch?Intermediate