Slow Downstream Service
Question
Service A calls Service B, which calls Service C. Service C becomes extremely slow and Service A starts failing because of timeouts. What pattern would you implement?
Short interview answer
Implement a Circuit Breaker so Service B stops calling the unhealthy Service C after repeated failures or timeouts. It fails fast instead of waiting for more timeouts, preventing resource exhaustion and cascading failure back to Service A.
Detailed answer
I would put a circuit breaker around Service B's call to Service C. The problem is not only that C is slow; it is that every request waiting on C consumes a connection, a thread, memory, and queue capacity in B. If enough calls wait until they time out, B becomes unhealthy too, and A starts failing even though A may have no fault of its own.
Imagine C normally answers in 100 milliseconds but suddenly takes 30 seconds. At first, the breaker is CLOSED, so B calls C as usual and records the timeouts. Once failures cross a threshold, the breaker moves to OPEN. B stops sending requests to C and immediately returns a safe fallback, cached result, or clear failure. That fail-fast response frees B to continue serving the work it still can handle.
Timeout: 1 second Failure threshold: 5 timeouts in 10 seconds
09:00:00 B → C times out breaker: CLOSED
09:00:02 B → C times out breaker: CLOSED
09:00:08 Fifth timeout breaker: OPEN
09:00:09 B → C is skipped B returns a fallback immediately
09:00:38 One trial request breaker: HALF-OPEN
After a cooldown, the breaker becomes HALF-OPEN and allows only a small number of trial calls. If C is healthy again, the breaker closes and normal traffic resumes. If those calls still time out, it opens again rather than releasing a backlog of requests onto a dependency that has not recovered.
I would set the timeout below B's own request deadline, use bounded retries, and decide explicitly what an acceptable fallback is. A cached product description may be fine; a cached payment authorization is not. The circuit breaker does not repair C, but it contains the failure and prevents C from taking A and B down with it.