
Rate Limiting Implementation
This walks you through implementing rate limiting from token buckets to sliding windows, with examples in TypeScript and Python. You get Redis-based distributed rate limiting for multi-server setups, Express middleware you can drop in, and patterns for tiered limits and adaptive throttling. The best practices section is solid on the operational details: returning 429s with Retry-After headers, handling burst traffic, and not storing state in memory when you're running multiple instances. If you're building a public API or need to prevent abuse without breaking legitimate users during traffic spikes, the reference implementations cover the algorithms that actually matter in production.
- skills.sh installs
- 507
- GitHub stars
- 379
- last updated
- Aug 21, 2026
Install
$ npx -y skills add aj-geddes/useful-ai-prompts --skill rate-limiting-implementation --agent claude-codeInstalls into .claude/skills of the current project.
Files
Rate Limiting Implementation
Table of Contents
Overview
Implement rate limiting and throttling mechanisms to protect your services from abuse, ensure fair resource allocation, and maintain system stability under load.
When to Use
- Protecting public APIs from abuse
- Preventing DOS/DDOS attacks
- Ensuring fair resource usage across users
- Implementing API quotas and billing tiers
- Managing system load and backpressure
- Enforcing SLA limits
- Controlling third-party API usage
- Database connection management
Quick Start
Minimal working example:
interface TokenBucketConfig {
capacity: number;
refillRate: number; // tokens per second
refillInterval: number; // milliseconds
}
class TokenBucket {
private tokens: number;
private lastRefill: number;
private readonly capacity: number;
private readonly refillRate: number;
private readonly refillInterval: number;
private refillTimer?: NodeJS.Timeout;
Sponsors
Details
- Repository
- github.com/aj-geddes/useful-ai-prompts
- Categories
- Backend & APIs, AI & Agent Building
- First seen
- Jun 3, 2026
More from aj-geddes/useful-ai-prompts
All 258- Ssl Certificate Management505
- Stakeholder Communication505
- Database Migration Management504
- Test Automation Framework504
- Cicd Pipeline Setup503
- Form Validation503
- Stress Testing503
- Test Data Generation502
- Application Logging501
- Grafana Dashboard501
- Changelog Maintenance500
- Code Documentation500
- Api Reference Documentation499
- Database Performance Debugging499
- Reactive Programming496
- Api Pagination495
- Container Debugging494
- Nosql Database Design492
- User Persona Creation492
- Database Indexing Strategy491
- Api Response Optimization490
- Uptime Monitoring490
- Background Job Processing488
- Accessibility Compliance487