Menu

Five Ways a Redis Rate Limiter Breaks (and the Rule Behind Most of Them)
📰

Five Ways a Redis Rate Limiter Breaks (and the Rule Behind Most of Them)

DEV Community: redis·Somnath Khadanga·2 days ago
#R0f1d288
#devtoredis#devto#dev#redis#limiter
Long article (1623 words) — no AI summary yet.
Reading 0:00
15s threshold

"Design a rate limiter" is one of the most common system design questions. The usual answer is a counter in Redis: read the count, compare it with the limit, write the count plus one. It passes every test that sends one request at a time.

I spent a week building the version that holds up, as a runnable system in the interview-traps repo : one design lesson, five traps and a rollup. Each trap has the naive code, the fix and a proof test. This post is the short version: one rule that covers most of the bugs, the example that shows it best, and how the other bugs fit around it.

One caveat up front, from the repo itself: Redis in this week is an in-process stand-in ( shared/kv.ts ) with Redis semantics, so everything runs with nothing but Node. The clock is pinned and crashes are injected on purpose, so each run is repeatable.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.