Overview of governor
mastergovernor is a Rust library for regulating the flow of data using the Generic Cell Rate Algorithm (GCRA). It is designed to help programs manage the strain they place on external services or to allow services to regulate incoming user requests.
Key characteristics include:
- GCRA Implementation: Functionally equivalent to a leaky bucket but more efficient.
- High Performance: Uses a single
AtomicU64for state, updated via compare-and-swap operations. It is significantly faster than Mutex-based implementations (averaging 10x faster in multi-threaded scenarios). - Low Memory Footprint: The rate-limiting state requires only 64 bits.
- Continuous Updates: State is updated on a nanosecond scale whenever a request arrives, without requiring a background "drip" process.
- Compatibility: Targets Rust 2018 edition and supports
async/await.