simple-rate-limiter

A simple rate limiter that minimizes contention caused by overactive clients.

Design

This rate limiter is designed with the following goals:

  1. Limited potential for a maliciously overactive client to degrade the ability to serve others

  2. Minimal synchronization cost between CPU caches, while also being fairly accurate for smoothing out bursts of traffic

  3. Memory overhead linear in the amount of active keys

API

```rust pub struct RateLimiter;

impl RateLimiter { pub fn new(limit: usize, slots: usize) -> Arc; pub fn rotateslots(&self); pub fn checklimited(&self, key: K) -> bool; } ```

Micro benchmarks (not to be trusted, measure your own applications)

Machine details: AMD® Ryzen 5 3600, x86_64-pc-linux-gnu, SMT enabled