Introduction

API calls fail when circuit breaker triggered by downstream failures. This guide provides step-by-step diagnosis and resolution.

Symptoms

Typical error output:

bash
HTTP 503 Service Unavailable
Circuit breaker is OPEN
Too many failures detected, circuit tripped

Common Causes

  1. 1.Rate limiting or quota exceeded
  2. 2.Authentication or authorization failure
  3. 3.Network connectivity issues
  4. 4.Server-side error or misconfiguration

Step-by-Step Fix

Step 1: Check Current State

bash
# Test API endpoint
curl -v https://api.example.com/endpoint
# Check API logs
tail -f /var/log/api/error.log
# Verify API health
curl https://api.example.com/health

Step 2: Identify Root Cause

bash
# Test API connectivity
curl -v https://api.example.com/endpoint
# Check authentication
curl -H "Authorization: Bearer <token>" https://api.example.com/verify
# Review logs
tail -f /var/log/api/error.log

Step 3: Apply Primary Fix

```bash # Primary fix curl -X GET "https://api.example.com/endpoint" \ -H "Authorization: Bearer <valid-token>" \ -H "Content-Type: application/json"

# Verify response # Should return 200 OK with expected data ```

Step 4: Apply Alternative Fix

bash
# Alternative: Check configuration
cat /etc/api/config.yaml
# Review authentication
curl -I https://api.example.com/endpoint
# Check logs
grep -i error /var/log/api/*.log

Step 5: Verify the Fix

bash
curl -s -o /dev/null -w "%{http_code}" https://api.example.com/health
# Should return 200

Common Pitfalls

  • Not handling rate limit headers in client code
  • Using expired or invalid authentication tokens
  • Ignoring error response bodies with diagnostic information
  • Not implementing proper retry logic with exponential backoff

Best Practices

  • Implement circuit breaker pattern for API calls
  • Use connection pooling with appropriate timeouts
  • Cache responses when possible to reduce API load
  • Monitor API metrics and set up alerts
  • API Connection Timeout
  • API Authentication Failed
  • API Rate Limit Exceeded
  • API Server Error