Skip to content
_CORE
AI & Agentic Systems Core Information Systems Cloud & Platform Engineering Data Platform & Integration Security & Compliance QA, Testing & Observability IoT, Automation & Robotics Mobile & Digital Banking & Finance Insurance Public Administration Defense & Security Healthcare Energy & Utilities Telco & Media Manufacturing Logistics & E-commerce Retail & Loyalty
References Technologies Blog Know-how Tools
About Collaboration Careers
CS EN DE
Let's talk

Rate Limiting Algorithms

20. 06. 2025 1 min read intermediate

Protects APIs against overload and abuse.

Token Bucket

The bucket fills with tokens at a constant rate. Request = consumes a token. Empty = rejected. Allows bursts.

Leaky Bucket

Requests fall into the bucket and are processed at a constant rate. Smooths out bursts.

Fixed Window

Counts requests in fixed windows. Problem: double rate at window boundaries.

Sliding Window

Combines the precision of sliding with the efficiency of fixed.

Redis Implementation

– Sliding Window Counter local key = KEYS[1] local window = tonumber(ARGV[1]) local limit = tonumber(ARGV[2]) local now = tonumber(ARGV[3]) redis.call(‘ZREMRANGEBYSCORE’, key, 0, now - window) if redis.call(‘ZCARD’, key) < limit then redis.call(‘ZADD’, key, now, now .. math.random()) return 1 end return 0

HTTP Headers

X-RateLimit-Limit: 100 X-RateLimit-Remaining: 42 Retry-After: 30

Token Bucket for Most Use Cases

Most flexible — allows bursts, constant memory. Redis for distributed environments.

rate limitingalgoritmyapi
Share:

CORE SYSTEMS team

We build core systems and AI agents that keep operations running. 15 years of experience with enterprise IT.