Overview
The Health Check endpoint monitors API service availability and infrastructure connectivity. Used for load balancer health checks, monitoring dashboards, and deployment verification.Endpoint
GET/api/health
No authentication required - publicly accessible for monitoring.
Response Format
Healthy Response (200 OK)
Unhealthy Response (503 Service Unavailable)
Health Checks Performed
Database Connectivity
- Executes
SELECT 1query - Verifies PostgreSQL connection
- Times out after 5 seconds
Redis Connectivity
- Executes
PINGcommand - Verifies Redis cache availability
- Times out after 3 seconds
Strict Mode
Configuration
Set environment variable:STRICT_HEALTH_CHECK=true
Behavior
- Normal Mode (default): Returns 200 OK even with infrastructure issues (logs warnings)
- Strict Mode: Returns 503 when database or Redis unavailable (prevents unhealthy routing)
Use Cases
- Load Balancers: Use strict mode to automatically remove unhealthy instances
- Monitoring: Use normal mode for alerting without affecting traffic
- Development: Normal mode allows testing with partial infrastructure
Monitoring Integration
HTTP Status Codes
- 200: Service healthy
- 503: Service unhealthy (strict mode only)
Response Time
- Healthy: <100ms
- Warning: 100-500ms
- Critical: >500ms
Alert Conditions
- HTTP 503 responses
- Response time >1 second
- Database connection failures
- Redis connection failures
Deployment Verification
Use the health check to verify successful deployments:Load Balancer Configuration
Nginx Example
AWS ALB Health Check
Troubleshooting
Common Issues
Database Connection Failed:- Check PostgreSQL service status
- Verify connection string
- Check network connectivity
- Review database credentials
- Check Redis service status
- Verify Redis URL configuration
- Check network connectivity
- Review Redis authentication
Debug Mode
Enable detailed logging with environment variable:Business Continuity
- Health checks run independently of application logic
- No database writes performed during health checks
- Minimal resource usage (designed for high-frequency polling)
- Automatic recovery detection when services restore
