API Gateway with load balancing and circuit breaker.
docker compose up
curl http://localhost:8000/proxy/Gateway starts with 4 backends. One fails randomly to test circuit breaker behavior.
- Round-robin load balancing
- Circuit breaker isolates failing backends
- Health checks remove dead backends from rotation
- Auto-recovery after 30 seconds
# Load balancing
for i in {1..10}; do curl http://localhost:8000/proxy/; done
# metrics
curl http://localhost:8000/metrics
# Logs (circuit breaker open/close)
docker compose logs -f gatewayCopy .env.example to .env if needed. Defaults work fine.
Based on samwho.dev/load-balancing
API Gateway com load balancing e circuit breaker.
docker compose up
curl http://localhost:8000/proxy/Gateway inicia com 4 backends. Um deles falha randomicamente pra testar o circuit breaker.
- Balanceamento com round-robin
- Circuit breaker isola os backends com falha
- Health checks removem os backends mortos da rotação
- Recuperação é feita de forma automática após 30 segundos
# Balanceamento
for i in {1..10}; do curl http://localhost:8000/proxy/; done
# Métricas
curl http://localhost:8000/metrics
# Logs (ircuit breaker abre/fecha)
docker compose logs -f gatewayCopia .env.example pra .env se necessário. O padrão funciona.
Based on samwho.dev/load-balancing