Rate Limiting - Universal Skill

Implement token bucket rate limiting with Redis for distributed applications.

Updated Jun 7, 2024
One-click install
npx skills add https://github.com/ashishgurprit/ANLP_A3 --skill rate-limiting-universal-skill
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Rate Limiting - Universal Skill
Source: https://github.com/ashishgurprit/ANLP_A3/tree/main/.claude.backup/skills/rate-limiting-universal
Command: npx skills add https://github.com/ashishgurprit/ANLP_A3 --skill rate-limiting-universal-skill

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill provides robust, distributed rate limiting to protect your applications from abuse, brute-force attacks, and denial-of-service incidents.

Core Features & Use Cases

  • Prevent Abuse: Defend against brute-force login attempts, API abuse, and spam submissions.
  • Distributed Enforcement: Uses Redis for consistent rate limiting across multiple application instances.
  • Intelligent Algorithms: Implements the industry-standard Token Bucket algorithm, allowing bursts while maintaining average rates.
  • Use Case: Protect your public API by limiting requests per IP address and authenticated endpoints by user ID, ensuring fair usage and preventing resource exhaustion.

Quick Start

Apply the rate limiting middleware to your FastAPI application to protect the /api/auth/login endpoint with 5 requests per minute per IP.

Frequently Asked Questions about Rate Limiting - Universal Skill

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement rate limiting to prevent brute force attacks on my API?

To implement rate limiting against brute force attacks, you can use a token bucket algorithm with Redis for distributed storage. This limits requests per IP address or user ID, preventing API abuse and ensuring fair usage across instances.

What's the best way to enforce distributed rate limiting across multiple application instances?

Distributed rate limiting across multiple instances requires a centralized data store like Redis. Using Redis ensures consistent request tracking and enforcement, preventing users from bypassing limits by routing requests to different servers.

How does the token bucket algorithm work for API protection?

The token bucket algorithm allows bursts of traffic while maintaining an average request rate. Tokens are added to a bucket at a fixed interval; each request consumes a token, and requests are denied when the bucket is empty.

Can I limit API requests by both IP address and user ID?

Yes, you can apply combined rate limiting strategies. This allows you to restrict public endpoints by IP address and authenticated endpoints by user ID simultaneously, ensuring comprehensive API protection.

Do I need Redis to run this rate limiting solution?

Yes, Redis is required as a dependency. It provides the distributed storage necessary to track token bucket counts consistently across all your application instances.

How do I configure rate limits for a FastAPI login endpoint?

You can apply rate limiting middleware to your FastAPI application to protect specific endpoints like /api/auth/login. Configure parameters such as 5 requests per minute per IP to prevent spam and resource exhaustion.