PitchHut logo
django-smart-ratelimit
Async-ready, fault-tolerant rate limiting for Django.
Pitch

Most Django rate limiting solutions are sync-first and cache-only. Django Smart Ratelimit is a stateless, production-focused alternative with modern algorithms (Token Bucket / Sliding Window), Redis & async-friendly backends, and a built-in circuit breaker for safer behavior under load and backend failures.

Description

Django Smart Ratelimit

Django Smart Ratelimit is a powerful and efficient rate limiting library designed specifically for Django applications. This high-performance, stateless solution effectively safeguards APIs against abusive traffic while optimizing performance across distributed systems through atomic Redis operations and implementing circuit-breaking strategies.

Key Features

  • Stateless & Modern: It supports both synchronous and asynchronous operations without relying on database dependencies, allowing for optimal scalability.
  • Enterprise Reliability: Incorporates built-in circuit breaker and automatic failover strategies, ensuring continuous operation even under high traffic conditions.
  • Multiple Algorithms: Supports various rate limiting algorithms, including Token Bucket, Sliding Window, and Fixed Window, providing flexibility according to different needs.
  • Flexible Backends: Compatible with multiple backends, including Redis (recommended), Async Redis, Memory, or custom options, catering to different architectural setups.
  • Precise Control: Enables detailed rate limiting based on IP address, user identity, HTTP headers, or any custom callable for tailored security measures.

Usage Example

To demonstrate its ease of use, here’s a quick implementation example:

from django_smart_ratelimit import ratelimit

@ratelimit(key='ip', rate='5/m', block=True)
def login_view(request):
    # If the limit is exceeded, this code receives a 429 Too Many Requests
    return authenticate(request)

Documentation

For comprehensive guidance, refer to the complete documentation organized in the docs/ folder, covering topics such as:

Community & Support

Engagement is encouraged through GitHub Discussions for idea sharing and Q&A, as well as the Issues section for reporting potential bugs.

0 comments

No comments yet.

Sign in to be the first to comment.