Python Rate-Limiter using Leaky-Bucket Algorithm for controlling request rates in applications with multiple backend storage options.
81
{
"context": "This criteria evaluates how well the engineer uses the pyrate-limiter package's RedisBucket functionality to implement a distributed rate limiting system. The focus is on proper usage of RedisBucket initialization, rate configuration with Rate and Duration classes, Limiter integration, and both synchronous and asynchronous rate limit checks.",
"type": "weighted_checklist",
"checklist": [
{
"name": "RedisBucket initialization",
"description": "Uses RedisBucket.init() class method to create bucket instance with Redis client connection and appropriate bucket_key parameter",
"max_score": 25
},
{
"name": "Rate configuration",
"description": "Correctly defines rate limits using Rate class with limit of 100 and Duration.MINUTE for the time interval",
"max_score": 15
},
{
"name": "Limiter integration",
"description": "Creates and uses Limiter instance initialized with the RedisBucket to perform rate limit checks",
"max_score": 15
},
{
"name": "Synchronous rate checking",
"description": "Uses limiter.try_acquire() method with user_id as the name parameter to check rate limits synchronously",
"max_score": 15
},
{
"name": "Asynchronous rate checking",
"description": "Uses limiter.try_acquire_async() method with user_id as the name parameter to check rate limits asynchronously with await",
"max_score": 15
},
{
"name": "Wait time calculation",
"description": "Uses bucket.waiting() method to calculate wait time in milliseconds when rate limit is exceeded",
"max_score": 10
},
{
"name": "State management",
"description": "Uses bucket.flush() or bucket operations to reset user limits and bucket.count() to retrieve current request counts",
"max_score": 5
}
]
}Install with Tessl CLI
npx tessl i tessl/pypi-pyrate-limiterdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10