Rewriting a shared Redis rate limiter
1 in 10requests timed out under burst, before my rewrite
- Problem
- Every server shared one limiter in front of a third-party API. Under burst, 1 in 10 requests timed out, and one server got 25× the turns of another.
- My call
- I reproduced it first with a 5-process burst test. Then I rewrote the core as one atomic Lua script that takes a slot and pops the next job in a single step.
- Result
- Fair turns from a random starting slot, an urgent lane for people who are waiting, timeouts that grow with the queue, and a backup provider before anything fails.
A teammate built the first version. I proposed and built the rewrite.
Try a small copy of it
- No requests yet.
0 served, 0 timed out and retried later.