Question presented to candidate: "A downstream payment provider your service depends on starts failing every request. Without any protection, what happens to YOUR service's own performance and stability, and how does a circuit breaker specifically prevent it?"
What a strong answer should cover:
- Without protection, every incoming request to your service keeps calling the failing downstream, and each of those calls still pays its full latency/timeout cost before failing — under load, this can exhaust your own service's connection pool or thread/event-loop capacity, meaning ONE failing downstream can genuinely take YOUR service down too, not just the requests that needed it (the "cascading failure" problem).
- 📌 Verified, not assumed: a real circuit breaker, wrapping a genuinely failing downstream function, opened after 3 real consecutive failures; a 4th call was then genuinely rejected immediately — confirmed by an unchanged real downstream call counter, proving the downstream was never even touched — before a real
resetTimeoutMshad elapsed, a HALF_OPEN trial call was allowed through, genuinely succeeded, and genuinely closed the circuit again. - 📌 Interview term: the three states, precisely — CLOSED (normal operation, calls pass through, failures are counted); OPEN (the failure threshold was hit — calls are rejected immediately WITHOUT touching the downstream at all, verified directly above); HALF_OPEN (after a reset timeout, exactly one trial call is allowed through to test if the downstream has recovered — success closes the circuit, failure reopens it).
- The core benefit, stated precisely: an OPEN circuit fails FAST (an immediate rejection, no downstream call, no timeout wait) instead of failing SLOW (every request still paying the downstream's full timeout before failing) — this is what actually prevents the cascading-failure scenario in the prompt, giving the struggling downstream genuine breathing room to recover instead of being hammered by a continuous stream of doomed retries.
- A precise answer distinguishes a circuit breaker from a plain retry: retrying a failing call adds MORE load to an already-struggling downstream (the opposite of helpful) — a circuit breaker and a retry policy are complementary, not interchangeable: retry a transient blip, but the circuit breaker's OPEN state exists specifically to stop retrying (and stop calling at all) once failures become sustained rather than transient.
Clarifying questions expected:
- "What should happen to a request while the circuit is OPEN — an immediate error, or a fallback/cached response?" — directly shapes the caller-facing behavior beyond the breaker's internal state machine.
- "What failure threshold and reset timeout are appropriate for this specific downstream's expected reliability and recovery time?" — these two numbers are the actual tuning knobs, not the state machine's logic itself.
Code / implementation expected: Yes — a real, complete circuit breaker with genuinely observed CLOSED → OPEN → HALF_OPEN → CLOSED transitions, including confirming the downstream is genuinely untouched during OPEN, is the concrete, convincing proof of the entire mechanism.