{"id":3266,"library":"rush","title":"Rush: Throttling Algorithms","description":"Rush is a Python library that provides a composable and extensible framework for implementing various rate limiting algorithms and storage backends. It includes a periodic interval rate limiter, a leaky bucket rate limiter (Generic Cell Ratelimiting Algorithm - GCRA), and supports Redis and in-memory dictionary storage. The library emphasizes type annotations and requires Python 3.6 or newer. The current version is 2021.4.0, released in April 2021.","status":"maintenance","version":"2021.4.0","language":"python","source_language":"en","source_url":"https://github.com/sigmavirus24/rush","tags":["throttling","rate-limiting","algorithms","redis","concurrency","api"],"install":[{"cmd":"pip install rush","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Required for using the Redis storage backend.","package":"redis","optional":true}],"imports":[{"symbol":"quota","correct":"from rush import quota"},{"symbol":"throttle","correct":"from rush import throttle"},{"symbol":"PeriodicLimiter","correct":"from rush.limiters import periodic"},{"symbol":"DictionaryStore","correct":"from rush.stores import dictionary"}],"quickstart":{"code":"from rush import quota\nfrom rush import throttle\nfrom rush.limiters import periodic\nfrom rush.stores import dictionary\n\nt = throttle.Throttle(\n    limiter=periodic.PeriodicLimiter(\n        store=dictionary.DictionaryStore()\n    ),\n    rate=quota.Quota.per_hour(\n        count=5000,\n        burst=500,\n    ),\n)\n\nlimit_result = t.check('expensive-operation/user@example.com', 1)\n\nprint(f\"Limited: {limit_result.limited}\")\nprint(f\"Remaining: {limit_result.remaining}\")\nprint(f\"Reset after: {limit_result.reset_after}\")","lang":"python","description":"This quickstart demonstrates how to set up a basic periodic rate limiter using an in-memory dictionary store, defining a quota of 5000 requests per hour with a burst of 500. It then checks if an operation is limited and prints the result, remaining allowance, and reset time."},"warnings":[{"fix":"Refer to the official documentation for the latest recommended API usage and be prepared for potential changes to higher-level abstractions in future updates.","message":"The library's API is explicitly described as 'preliminary' and 'experimental'. While current imports are promised not to break, 'porcelain' (higher-level abstractions) may be added in future versions, potentially altering the recommended usage patterns.","severity":"gotcha","affected_versions":"2021.4.0 and earlier"},{"fix":"Evaluate if the existing feature set meets your needs and be aware that new features or rapid bug fixes may not be a priority for the maintainers.","message":"The last release (2021.4.0) was in April 2021. While the project is marked as 'Production/Stable', development activity appears to be infrequent. Users seeking actively developed or frequently updated libraries might need to consider this pace.","severity":"gotcha","affected_versions":"2021.4.0 and later"}],"env_vars":null,"search_vec":"'2021':70 '2021.4.0':66 '3.6':59 'algorithm':3,21,40,75 'annot':55 'api':78 'april':69 'backend':24 'bucket':34 'cell':38 'compos':12 'concurr':77 'current':63 'dictionari':49 'emphas':53 'extens':14 'framework':15 'gcra':41 'generic':37 'implement':17 'in-memori':46 'includ':26 'interv':29 'leaki':33 'librari':8,52 'limit':20,31,36,74 'memori':48 'newer':61 'period':28 'provid':10 'python':7,58 'rate':19,30,35,73 'rate-limit':72 'ratelimit':39 'redi':44,76 'releas':67 'requir':57 'rush':1,4 'storag':23,50 'support':43 'throttl':2,71 'type':54 'various':18 'version':64","created_at":"2026-04-11T09:28:08.895252+00:00","updated_at":"2026-04-16T21:14:37.951346+00:00","problems":[{"fix":"Install the `rush-redis` package using pip: `pip install rush-redis`","cause":"The `rush_redis` package, which provides Redis storage for Rush, is a separate dependency and is not installed by default with the main `rush` library.","error":"ModuleNotFoundError: No module named 'rush_redis'"},{"fix":"Instantiate a storage backend and pass it to the `Limiter` constructor: `limiter = Limiter(storage=MemoryStorage())`","cause":"The `rush.Limiter` class constructor requires a storage backend instance (e.g., `MemoryStorage` or `RedisStorage`) to be explicitly passed as the `storage` argument.","error":"TypeError: __init__() missing 1 required positional argument: 'storage'"},{"fix":"Ensure all numeric arguments to rate limiter configurations like `Interval` or `GCRA` are passed as integers or floats: `@limiter.limit(Interval(seconds=1, max_requests=5))`","cause":"This error typically occurs when non-integer or non-numeric types are passed to arguments that expect numbers (e.g., `max_requests` in `Interval` or `rate` in `GCRA`), leading to comparison failures in the rate limiting logic.","error":"TypeError: '<' not supported between instances of 'str' and 'int'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2021.4.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/sigmavirus24/rush","docs":null,"changelog":null,"pypi":"https://pypi.org/project/rush/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-29","next_check":"2026-07-28","install_tag":null}}