Rate Limiting
Protecting server resources from exhaustion by restricting client request frequency thresholds.
What you'll learn
- Fixed Window
- Sliding Window
- Token Bucket
- Leaky Bucket
TL;DR
Protecting server resources from exhaustion by restricting client request frequency thresholds.
Visual System Topology
Token Bucket Rate Limiter
Concept Overview
Rate limiting restricts the number of requests a client can make in a given time window. It protects servers from being overwhelmed by too many requests, whether from legitimate traffic spikes or malicious attacks.
Common algorithms include Token Bucket, Leaky Bucket, Fixed Window, and Sliding Window.
Key Architectural Pillars
Fixed Window
Allow N requests per fixed time window (e.g., 100 requests per minute). Simple but can have burst at window boundaries.
Sliding Window
Smooth rate limiting using weighted counts from current and previous window. More accurate but slightly more complex.
Token Bucket
Bucket fills with tokens at fixed rate. Each request consumes a token. Allows bursts while maintaining average rate.
Leaky Bucket
Requests enter bucket, leak out at fixed rate. Smooths bursts. Queue-based approach.
