Overview of rate limiting algorithms in limiters
masterThe limiters library provides several distributed rate limiting algorithms for Golang, each with different characteristics and backend support:
- Token bucket: Allows requests at a specific input rate with configurable bursts (via
capacity). It is precise but requires a distributed lock. Supported backends: in-memory, redis, memcached, etcd, dynamodb, cosmos db. - Leaky bucket: Uses a FIFO queue to process requests at a constant rate. Input rate is only restricted by the queue capacity. Requires a lock. Supported backends: in-memory, redis, memcached, etcd, dynamodb, cosmos db.
- Fixed window counter: A resource-efficient algorithm that does not require a lock. It may be lenient at window boundaries. Supported backends: in-memory, redis, memcached, dynamodb, cosmos db.
- Sliding window counter: Smoothes out bursts at window boundaries by using two windows instead of one. It uses twice the memory of Fixed Window and may disallow all requests if a client is flooding the service. Supported backends: in-memory, redis, memcached, etcd, dynamodb, cosmos db.
- Concurrent buffer: Allows concurrent requests up to a specified capacity. Requires a lock. Supported backends: in-memory, redis, memcached.