Imagine you have many small services talking to each other. Sometimes one service might be slow or broken. What does the circuit breaker pattern mainly help with?
Think about how to stop repeated failures from making things worse.
The circuit breaker pattern stops calls to a failing service after a threshold to prevent cascading failures and system overload.
In a circuit breaker, one part counts how many times a service call fails. Which component does this?
Focus on the part that decides when to open the circuit.
The failure counter inside the circuit breaker tracks failed calls to decide when to open the circuit and stop calls.
When many users use a system, some services might slow down or fail. How does the circuit breaker help the system handle more users smoothly?
Think about how stopping bad calls helps the system breathe.
When the circuit breaker stops calls to failing services, it prevents resource waste and allows the system to serve healthy requests efficiently, improving scalability.
Choosing how many failures trigger the circuit breaker is tricky. What is the main tradeoff?
Think about reacting too quickly versus too late.
If the failure threshold is too low, the circuit breaker may open unnecessarily (false alarms). If too high, it may keep calling a failing service too long, causing more problems.
A circuit breaker is configured with a failure threshold of 5 failures within a 1-minute window. If the service receives 100 requests per minute and 4% of requests fail, how many failed requests will occur before the circuit breaker opens?
Calculate 4% of 100 requests, then compare to threshold.
4% of 100 requests = 4 failures per minute, which is below the threshold of 5. The circuit breaker opens only after 5 failures.