A rate limiter service built in Rust using multiple algorithms. Designed to be fast, modular, scalable and easy to use.
- Token Bucket Algorithm
- Leaky Bucket Algorithm
- Fixed Window Algorithm
- Sliding Window Log Algorithm
- Sliding Window Counter ALgorithm
cargo runServer runs on http://localhost:8000
GET /- A simple hello world route.GET /unlimited- An endpoint without any rate limiting.GET /limited/tb- An endpoint protected by the Token Bucket algorithm.GET /limited/lb- An endpoint protected by the Leaky Bucket algorithm.GET /limited/fw- An endpoint protected by the Fixed Window algorithm.GET /limited/swl- An endpoint protected by the Sliding Window Log algorithm.GET /limited/swc- An endpoint protected by the Sliding Window Counter algorithm.
| Algorithm | Avg Time |
|---|---|
| Fixed Window | ~120 ms |
| Sliding Log | ~123 ms |
| Sliding Counter | ~126 ms |
| Leaky Bucket | ~126 ms |
| Token Bucket | ~128 ms |
- All algorithms have similar runtime cost
- Differences come from fairness and memory usage
- Token Bucket / Sliding Counter → best tradeoff
- Fixed Window → fastest but bursty
- Sliding Log → accurate but higher memory
