Asked about Working through the classic designs

How would you design a rate limiter?

An answer that works

Token bucket: tokens refill at a fixed rate, each request spends one, and bursts are allowed up to the bucket size. Distributed, it needs shared state in a fast store with atomic check-and-decrement to avoid races between servers.

Reading an answer is not being able to give one. The section that teaches this is Working through the classic designs, 4 hours of Distributed systems.

Learn this properly