Novo curso: Como conseguir vagas remotas em empresas que pagam $120k+/ano
NaGringa
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.

Empresas em que apareceu
MicrosoftMicrosoft
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

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.

Anexos públicos

Materiais associados

Nenhum anexo público associado a esta pergunta.

Próximo passo

Depois de treinar essa pergunta, vale abrir outras do mesmo tipo e da mesma senioridade para comparar padrões de resposta.

Isso ajuda a sair da memorização de uma resposta só e entrar em repertório real de entrevista.

Continue a preparação com o banco completo

No app você encontra perguntas parecidas, compara empresas e aprofunda essa busca com mais filtros.