Examples & Use Cases
Real-world configurations for common rate-limiting scenarios.
Stripe-Style Rate Limiting
Allow bursts of traffic but enforce a long-term limit. Perfect for APIs that have variable traffic patterns.
yaml
algorithm: TOKEN_BUCKET
capacity: 100 # Allow burst of 100 requests
refillRate: 10 # 10 new tokens per second
# Long-term: 600 requests per minuteDatabase Protection
Process queries at a constant rate to prevent overwhelming the database during traffic spikes.
yaml
algorithm: LEAKY_BUCKET
capacity: 50 # Maximum queue size
flowRate: 5 # Process 5 queries per second
# Smooths out traffic spikesStrict API Quota
Enforce precise rate limits for billing or SLA purposes. No boundary loopholes.
yaml
algorithm: SLIDING_WINDOW
maxRequests: 1000 # Exactly 1000 requests allowed
windowTime: 3600000 # Per hour (3600 seconds)
# Strict enforcementSimple Internal Service
Fast, memory-efficient rate limiting for internal APIs where high accuracy is not critical.
yaml
algorithm: FIXED_COUNTER
maxRequests: 10000 # 10,000 requests per window
windowSize: 60 # Per minute
# Simplest and fastest implementationPer-User-Tier Configuration
Apply different rate limits based on user subscription tier using user-tiers configuration:
yaml
- path: /api/data
user-tiers:
free:
algorithm: FIXED_COUNTER
maxRequests: 100
windowSize: 3600
premium:
algorithm: TOKEN_BUCKET
capacity: 10000
refillRate: 100
enterprise:
algorithm: SLIDING_WINDOW
maxRequests: 1000000
windowTime: 60000