Rate Limiting, Cells, and GCRA
6 days ago
- #GCRA
- #rate-limiting
- #Throttled
- Rate limiting is essential for controlling access to services and preventing abuse.
- A simple rate limiting method uses a bucket with a fixed limit that expires after a set time, but it can be harsh on users and servers.
- The leaky bucket algorithm provides smoother rate limiting by allowing gradual quota replenishment but relies on a background process that can fail.
- GCRA (Generic Cell Rate Algorithm) is a sophisticated rate limiting method that avoids the need for a background process by tracking theoretical arrival times.
- GCRA was originally used in ATM networks and is now implemented in modern tools like the Throttled library.
- Throttled is an open-source Go library that implements GCRA and is used in production by companies like Stripe and Heroku.
- Consistent time synchronization is crucial for GCRA to prevent false positives in rate limiting.
- GitHub's API uses a naive rate limiting approach, which can be problematic for users who exhaust their limits quickly.