FlowGuard: Dynamic Concurrency Control for Rust

⚓ Rust    📅 2025-12-27    👤 surdeus    👁️ 3      

surdeus

Hi Rust community!

I just published FlowGuard v0.2.1 - a library for adaptive concurrency control and backpressure in Rust services.

:bullseye: 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

:rocket: The Solution

FlowGuard implements the TCP Vegas congestion control algorithm to dynamically adjust concurrency limits based on real-time latency.

:sparkles: Key Features

  • :white_check_mark: Dynamic backpressure - Limits adjust in real-time, not static!
  • :white_check_mark: Vegas algorithm - Proven congestion control from TCP
  • :white_check_mark: Tower/Axum integration - Middleware for web services
  • :white_check_mark: Observability - current_limit() and available_permits() methods
  • :white_check_mark: Zero manual tuning - Self-adjusting based on system health

:package: 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;
}

:link: Links

:bullseye: 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

Read full topic

🏷️ Rust_feed