Design a low-level Circuit Breaker for a service that makes synchronous API calls to an external dependency. The circuit breaker should support three states: CLOSED, OPEN, and HALF_OPEN. In the CLOSED state, all requests are allowed and failures are counted; if the number of failures crosses a configurable failureThreshold within a sliding time window, the circuit should transition to the OPEN state. In the OPEN state, all incoming requests should be short-circuited immediately and a fallback response should be returned; after a configurable timeoutDuration, the circuit should move to the HALF_OPEN state. In the HALF_OPEN state, only a limited number of test requests should be allowed; if a configurable successThreshold of consecutive successful calls is reached, the circuit should transition back to CLOSED, otherwise any failure should move it back to OPEN. The design should be thread-safe, configurable, and easily integrable with a REST client, and should expose metrics such as failure count, state transitions, and request rejections.
TechnicalSenior
Design a Circuit Breaker
Design a low-level circuit breaker system for managing API calls to external dependencies, supporting three states (CLOSED, OPEN, HALF_OPEN) with configurable failure thresholds, timeout durations, and automatic state transitions. The system should be thread-safe, provide fallback responses, and expose metrics for monitoring service reliability.
Contextos reais
Onde essa pergunta já apareceu
Use esses exemplos para entender em que contexto ela costuma cair e adaptar sua prática.
Microsoftseniordez. de 2025
Anexos públicos
Materiais associados
Nenhum anexo público associado a esta pergunta.
Sinais de resposta forte
Você conecta fundamento técnico com uma decisão real de produto ou arquitetura.
Seu raciocínio mostra contexto, restrições e impacto prático.
Os follow-ups deixam sua profundidade mais clara em vez de expor fragilidade.
O que costuma enfraquecer a resposta
Responder só com definição teórica e sem caso real.
Trazer detalhes demais sem conectar ao problema que estava sendo discutido.
Dar uma resposta certa no papel, mas sem mostrar julgamento prático.
Continue a preparação com o banco completo
No app você encontra perguntas parecidas, compara empresas e aprofunda essa busca com mais filtros.