Skip to content
Researched developer tool comparisonsPrices dated · vendor sources linked · no star ratings
Search

Stage 02 · Test · Researched comparison

Best Python Rate Limiting Libraries in 2026

Slowapi suits most teams that need request throttling in a FastAPI or Starlette app, because it wraps the familiar limits library in route decorators. For framework-agnostic control inside your own code, limits is the safer base layer. For distributed limits across several processes or hosts, the Redis-backed storage options in limits are the practical picks.

By
Published 27 Nov 2026 · 6 tools compared

We run no ads and no affiliate links at launch. The order of a list follows our published method. See how we score.

Prices are the starting prices vendors list publicly. Plans change, so confirm the current price on the vendor page before you buy.

Key takeaways

  • Slowapi fits FastAPI and Starlette apps and builds on the limits library, so the two share the same storage backends.
  • limits is framework-agnostic and supports in-memory, Redis, Memcached and MongoDB storage.
  • All five libraries listed here are free and open source, so cost is not a deciding factor.
  • Rate limiting libraries only count requests; they do not encrypt traffic or protect secrets, so keep credentials out of logs.

Who each pick is for

  • FastAPI and Starlette apps that want decorator-based limitsSlowapi
  • Framework-agnostic rate limiting with pluggable storage backendslimits
  • Flask applications that need per-route and global limitsFlask-Limiter
  • Django views that need simple per-IP or per-key limitsdjango-ratelimit
  • Asyncio code that needs a leaky-bucket limiteraiolimiter
  • Simple in-process token bucket with optional thread safetytoken-bucket

Comparison

The 6 tools at a glance
ToolBest forStandout featureListed starting priceFree plan or trial
1SlowapiFastAPI and Starlette apps that want decorator-based limitsDecorator syntax that reads well in route handlersFree (open source)Free plan
2limitsFramework-agnostic rate limiting with pluggable storage backendsWide choice of storage backends including Redis, Memcached and MongoDBFree (open source)Free plan
3Flask-LimiterFlask applications that need per-route and global limitsNative Flask extension with decorators and app-wide defaultsFree (open source)Free plan
4django-ratelimitDjango views that need simple per-IP or per-key limitsSmall decorator API that fits Django viewsFree (open source)Free plan
5aiolimiterAsyncio code that needs a leaky-bucket limiterAsync-native API that fits asyncio clients and servicesFree (open source)Free plan
6token-bucketSimple in-process token bucket with optional thread safetyVery small dependency-free implementationFree (open source)Free plan

How we picked

We picked libraries that are actively maintained, have a public repository and documentation, and do the specific job of rate limiting in Python. We weighed framework fit (FastAPI, Flask, Django, asyncio or none), storage options and whether limits can be shared across processes, licence terms, and the practical limits each library states in its docs. Sources are vendor pages, project repositories and documentation. Prices and plan details can change, so confirm on the vendor site before you commit.

The tools, one by one

01

Slowapi

Best for fastAPI and Starlette apps that want decorator-based limits

Visit github.com
Slowapi homepage
Slowapi homepage, captured Nov 2026

What it is and where it fits

Slowapi adds rate limiting to FastAPI and Starlette by wrapping the limits library. You decorate a route with a limit string such as "5/minute" and the library enforces it per client, keyed by remote address by default. You can supply a custom key function to limit by API key, user ID or any other request attribute.

Storage is delegated to limits, so you can keep counters in memory for a single process or point them at Redis or Memcached for multi-process deployments. In-memory storage resets when the process restarts and is not shared between workers, which matters if you run several Uvicorn or Gunicorn workers behind a load balancer. The project is MIT licensed and free to use.

Skip it if you are not on FastAPI or Starlette; the decorators expect Starlette request objects, so a Flask or Django project is better served by a different library.

Standout: Decorator syntax that reads well in route handlers

Pricing pointer

Free (open source), as listed by the vendor (Slowapi website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Decorator syntax that reads well in route handlers
  • reuses the limits storage backends

Drawbacks

  • Tied to Starlette request objects
  • smaller project than the underlying limits library

Skip it if this limit matters to you: tied to Starlette request objects.

Verdict. A sensible pick for fastAPI and Starlette apps that want decorator-based limits.

Alternatives in this guide: limits, Flask-Limiter, django-ratelimit

02

limits

Best for framework-agnostic rate limiting with pluggable storage backends

Visit github.com
limits homepage
limits homepage, captured Nov 2026

What it is and where it fits

limits is a lower-level library. It gives you a strategy object and a storage object, and you call hit() or test() to record and check usage. It supports fixed windows, moving windows, sliding window counters and token buckets, so you can match the algorithm to how strict you need the limit to be.

Because it has no web framework dependency, it works in Flask, Django, FastAPI, background workers or plain scripts. Storage backends include in-memory, Redis, Memcached, MongoDB and others, which is what makes it usable for limits shared across hosts. The in-memory backend is per-process only.

The trade-off is that you handle the HTTP side yourself: returning 429 responses, adding headers and choosing the key. The library is MIT licensed and free. Teams that want decorators out of the box should look at a framework integration instead.

Standout: Wide choice of storage backends including Redis, Memcached and MongoDB

Pricing pointer

Free (open source), as listed by the vendor (limits website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Wide choice of storage backends including Redis, Memcached and MongoDB
  • used as the engine under several frameworks

Drawbacks

  • No HTTP integration on its own
  • you write the request handling code

Skip it if this limit matters to you: no HTTP integration on its own.

Verdict. A sensible pick for framework-agnostic rate limiting with pluggable storage backends.

Alternatives in this guide: Slowapi, Flask-Limiter, django-ratelimit

03

Flask-Limiter

Best for flask applications that need per-route and global limits

Visit github.com
Flask-Limiter homepage
Flask-Limiter homepage, captured Nov 2026

What it is and where it fits

Flask-Limiter is the Flask extension built on limits. You can set a default limit for the whole app, override it per route with a decorator, and choose a key function so limits apply per IP, per user or per API token. It handles the 429 response and rate limit headers for you.

Storage follows limits, so a single-process app can use memory while a multi-worker deployment should use Redis or Memcached. The extension also supports exemptions for certain routes and dynamic limits that depend on the request. It is MIT licensed and free.

If your stack is Django, this is not the right tool; look for a Django-specific package or call limits directly. For Flask projects it removes most of the boilerplate.

Standout: Native Flask extension with decorators and app-wide defaults

Pricing pointer

Free (open source), as listed by the vendor (Flask-Limiter website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Native Flask extension with decorators and app-wide defaults
  • same storage backends as limits

Drawbacks

  • Flask only
  • configuration surface is large for simple cases

Skip it if this limit matters to you: flask only.

Verdict. A sensible pick for flask applications that need per-route and global limits.

Alternatives in this guide: Slowapi, limits, django-ratelimit

04

django-ratelimit

Best for django views that need simple per-IP or per-key limits

Visit github.com
DRdjango-ratelimitgithub.com
Homepage screenshot not available; visit the vendor site.

What it is and where it fits

django-ratelimit provides a ratelimit decorator and a middleware option for Django. You specify a rate such as "100/h" and a key, often the client IP or a header value, and the decorator blocks requests over the limit. Blocked requests return 403 by default, which you can change.

Counters live in the Django cache, so the backend you configure for caching decides whether limits are shared across processes. The local-memory cache is per-process; a shared cache such as Redis or Memcached makes limits consistent across workers. The package is BSD licensed and free.

It is a focused tool: fixed-window counting, no token bucket. If you need sliding windows or several algorithms in one codebase, limits gives you more control. For a typical Django view that needs a simple throttle, it is enough.

Standout: Small decorator API that fits Django views

Pricing pointer

Free (open source), as listed by the vendor (django-ratelimit website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Small decorator API that fits Django views
  • uses the Django cache framework for storage

Drawbacks

  • Django only
  • algorithm choice is narrower than limits

Skip it if this limit matters to you: django only.

Verdict. A sensible pick for django views that need simple per-IP or per-key limits.

Alternatives in this guide: Slowapi, limits, Flask-Limiter

05

aiolimiter

Best for asyncio code that needs a leaky-bucket limiter

Visit github.com
aiolimiter homepage
aiolimiter homepage, captured Nov 2026

What it is and where it fits

aiolimiter provides an asyncio-compatible leaky-bucket limiter. You create a limiter with a rate and capacity, then await acquire() before each outbound call. It is aimed at controlling the pace of async work such as API client calls, scraping loops or queue consumers.

Because it holds state in the process, each worker enforces its own limit. If you run four workers with a limit of 10 per second, the effective total can reach 40 per second. For a hard global cap you need shared storage, which this library does not provide.

It does not plug into a web framework and does not return HTTP responses; it just paces coroutines. The project is MIT licensed and free. Use it when the limit is about protecting an upstream service from your own client code.

Standout: Async-native API that fits asyncio clients and services

Pricing pointer

Free (open source), as listed by the vendor (aiolimiter website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Async-native API that fits asyncio clients and services
  • simple leaky-bucket model

Drawbacks

  • In-process only, so no shared state across workers
  • not an HTTP middleware

Skip it if this limit matters to you: in-process only, so no shared state across workers.

Verdict. A sensible pick for asyncio code that needs a leaky-bucket limiter.

Alternatives in this guide: Slowapi, limits, Flask-Limiter

06

token-bucket

Best for simple in-process token bucket with optional thread safety

Visit github.com
token-bucket homepage
token-bucket homepage, captured Nov 2026

What it is and where it fits

token-bucket is a small library from the Falcon project that implements the token bucket algorithm. You create a bucket with a capacity and a refill rate, then consume tokens before doing work. A thread-safe variant is available for multi-threaded servers.

It has no storage backend and no framework integration, so limits are per-process and reset on restart. That is fine for smoothing bursts inside one service, but not for a shared quota across a cluster. The codebase is small enough to read in one sitting, which some teams prefer over a larger dependency.

It is free and open source. Choose it when you want a few lines of throttling logic and nothing more, and reach for limits or a Redis-backed option when limits must be global.

Standout: Very small dependency-free implementation

Pricing pointer

Free (open source), as listed by the vendor (token-bucket website). Confirm the current plan price before you buy.

Free plan. Plans change, so confirm on the vendor's pricing page before you buy.

Benefits

  • Very small dependency-free implementation
  • thread-safe option for threaded servers

Drawbacks

  • In-memory only
  • minimal feature set

Skip it if this limit matters to you: in-memory only.

Verdict. A sensible pick for simple in-process token bucket with optional thread safety.

Alternatives in this guide: Slowapi, limits, Flask-Limiter

Who should use what

A FastAPI team adding per-route throttles should start with Slowapi. A Flask app that wants app-wide defaults and per-route overrides should use Flask-Limiter. A Django project with simple view throttling needs django-ratelimit. A team that must enforce one quota across many workers or hosts should use limits with Redis storage. Async client code that calls a third-party API should use aiolimiter to pace outbound requests.

Questions to settle before you buy

What to check before you buy

  • Confirm whether limits must be shared across workers or hosts, and pick a storage backend that supports that.
  • Check the algorithm: fixed window, sliding window or token bucket behave differently at window edges.
  • Verify the key you limit on, such as IP, API key or user ID, is available and trustworthy behind your proxy.
  • Read how the library reports limits, including 429 responses and rate limit headers, if clients depend on them.
  • Confirm the licence and maintenance activity of the repository before adding the dependency.

FAQ

Do I need Redis for Python rate limiting?

Only if limits must be shared across processes or hosts. In-memory backends in limits, Slowapi and aiolimiter are per-process, so several workers each enforce their own count. Redis or Memcached storage gives one shared counter.

Which library works with FastAPI?

Slowapi is built for FastAPI and Starlette and uses decorators on routes. You can also call limits directly inside a dependency if you want more control over keys and responses.

What is the difference between limits and Flask-Limiter?

limits is the framework-agnostic engine. Flask-Limiter is a Flask extension that wraps limits and adds decorators, default limits and 429 handling. Use Flask-Limiter in Flask apps and limits elsewhere.

Can these libraries limit outbound API calls?

Yes. aiolimiter and token-bucket pace outbound calls in your own code. For a global cap across many workers, use a Redis-backed limiter instead of an in-process one.

Is rate limiting the same as authentication?

No. Rate limiting counts and caps requests. It does not verify who the caller is. Use it alongside authentication and input validation, not as a replacement.

Sources we checked

Method: how we score · editorial policy.

  1. Slowapi (official site)
  2. limits (official site)
  3. Flask-Limiter (official site)
  4. django-ratelimit (official site)
  5. aiolimiter (official site)
  6. token-bucket (official site)

Change log. First published 27 Nov 2026.