Written by Somnath Khadanga
"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 mos...