Sliding-window rate limiting, from one process to a fleet.
Trypema gives Rust services independently built local, Redis, and hybrid providers. Use binary admission or gradual probabilistic shedding without changing the underlying rate model.
[dependencies] trypema = "2"
use trypema::{RateLimit, RateLimitDecision, RateLimiterBuilder}; use trypema::local::LocalRateLimiterProvider; fn main() { let provider = LocalRateLimiterProvider::builder().build().unwrap(); let rate = RateLimit::per_second_or_panic(10.0); match provider.absolute().inc("user_123", &rate, 1) { RateLimitDecision::Allowed => println!("allowed"), RateLimitDecision::Rejected { retry_after, .. } => { println!("retry in {retry_after:?}"); } RateLimitDecision::Suppressed { .. } => unreachable!(), } }
Choose where state lives
All providers expose absolute and suppressed limiters. The difference is latency, coordination, and how current each instance's view can be.

One explicit rate model
A RateLimit is normalized per second. Multiplying it by WindowSize gives the live-window
capacity; BucketSize controls how nearby increments are grouped.
Know the production boundaries
Best-effort concurrency
Admission is not a strict cross-caller transaction. Concurrent callers can temporarily overshoot a limit.
Redis requirements
Redis and hybrid require Redis 7.2+ and exactly one crate feature: redis-tokio or redis-smol.
Go deeper

