rate-limiting

Design rate limiting strategies with token bucket, sliding window, and Redis-based distributed counting.

1|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts --skill rate-limiting-kalilurrahman
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rate-limiting
Source: https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts/tree/main/01-software-dev/rate-limiting
Command: npx skills add https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts --skill rate-limiting-kalilurrahman

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires redis, prometheus-client, express, pytest.

What problem does it solve? APIs without rate limiting are vulnerable to abuse, brute-force attacks, and resource exhaustion, while poorly designed limits frustrate legitimate users. This Skill guides you through designing production-grade rate limiting that balances abuse prevention with fair usage. ## Core Features & Use Cases - Algorithm Selection: Compares token bucket, sliding window, fixed window, and leaky bucket with working Python and Redis implementations for each. - Multi-Tier & Per-Endpoint Limits: Defines different limits for free/basic/premium tiers and stricter rules for sensitive endpoints like login (5 attempts per 15 minutes). - Distributed Enforcement: Provides atomic Redis Lua scripts, Express.js middleware, bypass rules, 429 response headers, and Prometheus monitoring. - Use Case: You are launching a public REST API and need to prevent scraping while allowing paying customers higher throughput. Use this Skill to implement a Redis-backed token bucket with tiered limits, proper Retry-After headers, and IP whitelisting for internal services. ## Quick Start Design a rate limiting strategy for my REST API with tiered limits for free and premium users using Redis.

Frequently Asked Questions about rate-limiting

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

FAQPage Schema
How do I implement rate limiting for a REST API?

Implement rate limiting by choosing an algorithm (token bucket is recommended for most APIs), storing counters in Redis, and returning 429 responses with Retry-After and X-RateLimit headers when limits are exceeded. Apply limits per-user for authenticated requests or per-IP for anonymous traffic.

Token bucket vs sliding window rate limiting, which should I use?

Token bucket allows controlled bursts with O(1) memory and suits most APIs, while sliding window log provides precise enforcement with no edge-case bursts but uses O(n) memory storing each request timestamp. Fixed window is simplest but allows 2x bursts at window boundaries.

How do I rate limit across multiple servers with Redis?

Use Redis with atomic Lua scripts that combine ZREMRANGEBYSCORE, ZCARD, and ZADD in a single operation to prevent race conditions across distributed servers. This ensures exactly the configured number of requests are allowed even under concurrent load.

Should rate limiting fail open or closed when Redis is down?

Rate limiters should fail open, allowing requests when Redis or the storage backend is unavailable. Availability takes priority over strict enforcement, since blocking all traffic due to a cache outage is worse than temporarily unenforced limits.

What rate limits should login endpoints have?

Critical endpoints like login and password reset need stricter limits than general API routes, typically 5 attempts per 15 minutes per user or IP. This mitigates brute-force and credential-stuffing attacks without affecting normal users.