Failover & Recovery
Automatic failover to disk when PostgreSQL is unavailable - zero message loss guaranteed.
How It Works
Normal Operation:
Client → Queen Server → PostgreSQL ✅
PostgreSQL Down:
Client → Queen Server → File Buffer ✅
↓ (retry in background)
→ PostgreSQL (when recovered)Zero Message Loss
Queen automatically:
- Detects PostgreSQL unavailability
- Buffers messages to disk
- Returns success to client
- Replays messages when database recovers
No configuration needed - failover is automatic!
File Buffer Location
Linux: /var/lib/queen/buffers/
macOS: /tmp/queen/
Custom location:
bash
FILE_BUFFER_DIR=/custom/path ./bin/queen-serverFeatures
- ✅ Zero message loss
- ✅ FIFO ordering preserved
- ✅ Automatic recovery
- ✅ Survives server crashes
- ✅ No client changes needed
Monitoring
bash
# Check buffer files
ls -lh /var/lib/queen/buffers/
# Count buffered events
wc -l /var/lib/queen/buffers/failover_*.bufRecovery Performance
- Recovery rate: ~10,000 events/second
- Example: 1M buffered events = ~100 seconds recovery
Best Practices
- Provision disk space for peak traffic (2-4 hours)
- Monitor buffer directory for file buildup
- Alert on database outages proactively
- Test failover regularly
