Back to problems

Design a Per-Message Rate Limiter

Low-Level Design · Amazon · Medium

Dictionary of Last Allowed Timestamp The core challenge is deciding instantly whether a message can be printed, given that we must enforce a 10‑second cooldown between printings of the same message. Because the stream is ordered by non‑decreasing timestamps, we can maintain a simple mapping from each message to the earliest future timestamp at which it would again be eligible — or equivalently, the timestamp of its most recent allowed printing. The rule: a request…

Checking your access…