Expand description
Rate limits that survive a second replica — RateLimits and shared.
ⓘ
// routes/api.rs
router.post("/login", login).middleware(limits::shared(
ThrottleRequests::per_minute(5)
.named("login")
.keyed_by(|request| request.input("email")),
));A bare ThrottleRequests counts in its own process, which is the right
default for development and for a single node. Behind a load balancer it
means five replicas each enforce “five attempts a minute” separately, and
the real limit is twenty-five.
For a page-view limiter that is a rounding error. For a credential limiter it is the difference between a control and a decoration, which is why the bootstrap says so at boot when it finds one over a per-process cache.
Structs§
- Rate
Limits - The store every shared limiter in this application counts in.
Functions§
- shared
- Count
throttlein the application’s shared store. - warn_
if_ rate_ limits_ are_ not_ shared - Say so when a route rate-limits against a per-process counter.