Skip to main content

Crate tower_acc

Crate tower_acc 

Source
Expand description

Adaptive concurrency control for Tower services.

This crate provides a ConcurrencyLimit middleware that dynamically adjusts the number of in-flight requests based on observed latency, rather than requiring a fixed limit chosen at deploy time. It is inspired by Netflix’s concurrency-limits library and the TCP Vegas congestion control algorithm.

§Quick start

use tower::ServiceBuilder;
use tower_acc::{ConcurrencyLimitLayer, Vegas};

let service = ServiceBuilder::new()
    .layer(ConcurrencyLimitLayer::new(Vegas::default()))
    .service(my_service);

§Pluggable algorithms

The built-in Vegas algorithm works well for most workloads. To implement a custom strategy, see the Algorithm trait.

Structs§

ConcurrencyLimit
Enforces an adaptive limit on the concurrent number of requests the underlying service can handle.
ConcurrencyLimitLayer
A Layer that wraps services with an adaptive ConcurrencyLimit.
Vegas
TCP Vegas–inspired adaptive concurrency limit strategy.

Traits§

Algorithm
An algorithm that dynamically adjusts the maximum number of allowed concurrent requests based on the observed traffic.