---
answer: direct
beat: system-design
source: 1 article · updated: August 6, 2026
---

How do you enforce token buckets in a distributed system?

Use Redis or Memcached to store per-client token state (tokens_available, last_refill_time). Each API gateway queries and updates this state atomically. Return `429 Too Many Requests` with a `Retry-After` header when the bucket is empty. Distribute tokens across gateways by keeping the refill rate low enough that skew is acceptable.

Answered in

Token Buckets: Bounding Rate Limits at the Edge

Fixed-window counters leak at boundaries. Token buckets refill steadily, absorb bursts, and bound the sustained rate strictly—the algorithm Stripe uses.

Crashtech Editorial August 6, 2026 System Design & Architecture

Read the full analysis

Other questions this article answers

More system design & architecture questions

Every answer on Crashtech is written by the editor of the article it comes from — never auto-summarised. Browse all answers or the System Design & Architecture beat.