FlowGuard: Dynamic Concurrency Control for Rust
⚓ Rust 📅 2025-12-27 👤 surdeus 👁️ 3Hi Rust community!
I just published FlowGuard v0.2.1 - a library for adaptive concurrency control and backpressure in Rust services.
The Problem
Static limits (like "max 100 connections") are problematic:
- Too high : System crashes before reaching the limit
- Too low : Wasted resources and refused legitimate traffic
The Solution
FlowGuard implements the TCP Vegas congestion control algorithm to dynamically adjust concurrency limits based on real-time latency.
Key Features
Dynamic backpressure - Limits adjust in real-time, not static!
Vegas algorithm - Proven congestion control from TCP
Tower/Axum integration - Middleware for web services
Observability - current_limit()andavailable_permits()methods
Zero manual tuning - Self-adjusting based on system health
Quick Start
[dependencies] flow-guard = "0.2.1"
use flow_guard::{FlowGuard, VegasStrategy};
use std::sync::Arc;
#[tokio::main]
async fn main() {
let strategy = Arc::new(VegasStrategy::new(10));
let guard = FlowGuard::new(Arc::clone(&strategy));
// Limits adjust automatically based on latency!
let result = guard.run(async {
// Your async task here
Ok::<_, &str>("Done!")
}).await;
}
Links
- GitHub : GitHub - cleitonaugusto/flow-guard: Adaptive concurrency control and backpressure for Axum/Tower services in Rust
- Crates.io : crates.io: Rust Package Registry
- Documentation : flow_guard - Rust
- Examples :
basic_usage.rsandserver_demo.rsin the repo
Use Cases
- Protecting databases from overload
- Rate limiting microservices
- Adaptive load balancing
- Preventing cascading failures
I'd love to get your feedback and hear about your use cases!
(This fixes the static semaphore issue from v0.2.0 - now actually adjusts dynamically!)
1 post - 1 participant
🏷️ Rust_feed