
Prometheus Backpressure Proxy
Adaptive Protection for Your Backend Services
๐ก๏ธ Dynamically shield your services from traffic overload using smart, metrics-driven congestion control.
Key Features
- ๐ Adaptive Traffic Management: Automatically adjusts request concurrency based on real-time Prometheus metrics
- ๐ Smart Scaling: Uses Additive Increase/Multiplicative Decrease (AIMD) algorithm
- ๐ฆ Configurable Limits: Set min and max concurrent request thresholds
- ๐ Multi-Signal Monitoring: Track system health across multiple metrics simultaneously
Quick Example
config := proxymw.BackpressureConfig{
EnableBackpressure: true,
BackpressureQueries: []BackpressureQuery{
{
Query: `sum(rate(http_server_errors_total[5m]))`,
// Start to throttle when error rate reaches 50%
WarningThreshold: 0.5,
// Hard throttling up to 100 CongestionWindowMax when error rate is >80%
EmergencyThreshold: 0.8,
}
},
CongestionWindowMin: 10,
CongestionWindowMax: 100,
}
How It Works
- ๐ญ Continuously monitor system metrics
- ๐ Dynamically adjust request throughput
- ๐ Automatically throttle when system stress detected
When to Use
- Protecting microservices from sudden traffic spikes
- Preventing cascading failures
- Maintaining system stability under unpredictable load
Quick Start
- Configure backpressure queries as Prometheus metrics
- Define min/max request windows
- Choose the server-side http proxy or client-side roundtripper
- Import the starter Grafana dashboard
- Let the proxy handle the rest!
Development
Installation
Build the docker-compose stack
make all
docker compose down
docker-compose up --build
Lint and Test
make test
make lintfix
Upgrade dependencies
make deps
Contributing
CONTRIBUTING.md