Concepts/6. Advanced Concepts/Token Bucket Rate Limiting Algorithm
🪣
6. Advanced ConceptsIntermediate🔒 LOCKED FOR FREE TIER

Token Bucket Rate Limiting Algorithm

← All 150+ Concepts

A bucket holds up to B tokens and refills at a constant rate R tokens/sec. Each incoming request consumes 1 token. If no tokens remain, requests are dropped.

STAFF ENGINEER TAKEAWAY: Allows for natural temporary bursts of traffic (up to bucket capacity) while strictly capping long-term sustained throughput.
🔒

Unlock Token Bucket Rate Limiting Algorithm & All 150+ Visual Architecture Deep Dives

This advanced distributed system deep-dive includes interactive packet visualizers, state machine transitions, and FAANG interview trade-off blueprints.

More Topics in 6. Advanced Concepts

🚦Rate Limiting & Traffic Throttling

Controls the rate of incoming network traffic to protect services from abusive traffic, scraping, DDoS attacks, and resource starvation.

💧Leaky Bucket Rate Limiting Algorithm

Requests enter a FIFO queue bucket. The bucket leaks requests out to the backend at a strictly constant smooth rate, smoothing out spiky traffic.

🪟Sliding Window Log & Counter

Tracks request timestamps in a sorted set (Redis ZSET) to compute precise request counts within any rolling 60-second window, eliminating boundary burst bugs.

🎯Consistent Hashing & Virtual Nodes

Maps both server nodes and cache keys onto a circular hash ring (0 to 2^32-1). When a server node is added or removed, only K/N keys need to be remapped.