The limiter keeps the timestamp of every request it lets through. When a request arrives, timestamps older than the window are dropped, and the request passes only if fewer than the limit are left. The window moves with time instead of resetting, so it is exact, but it stores one timestamp per request. Below, an attacker joins two ordinary users: watch who is refused when they share one log and when each has their own.
Each dot stands for 579 real requests. Time is not scaled. In the log, green dots are requests that were let through and red ones are refused requests kept in the log. The busiest stretch counts what got through in any 5 seconds in a row.
Busiest hour vs the daily average. The book's estimate uses 2x.
Real limits often use a minute or an hour; the animation stays short so you can watch timestamps age out.
1. Average requests per second
2. Peak requests per second
3. Allowed rate r
4. Limit in any window L
5. What is arriving right now
6. Memory for the log
Doubling DAU doubles the traffic, and because r and L are sized from that same traffic, it doubles them too. Every ratio stays the same, so the log behaves identically and only the number each dot stands for changes. The memory, though, does double: the log stores every request, however many there are.
Steps 1 and 2 are the estimation method from the back-of-the-envelope chapter of Alex Xu's System Design Interview, Vol. 1, including its 2x peak. Its rate limiter chapter describes the sliding window log: drop outdated timestamps, add the new one, and allow the request if the log is no bigger than the limit. Its worked example keeps a refused request's timestamp in the log, which is what the Refused requests stay in the log switch shows. Steps 3 to 6 join the two, written here.
Both come from one engineering post by Figma, which describes the technique and then explains why Figma did not use it.
ZREMRANGEBYSCORE), the new one is added (ZADD), and the size of the set (ZCARD) is the number of requests in the sliding window. Counting carries on after the limit is reached, which the post notes "would just extend a ban on a malicious user": the same effect as the switch above. One detail from the Redis documentation: members of a sorted set are unique, so two requests with the same timestamp need different member values.Figma's post is a first-hand account by the engineer who built their limiter (Nikrad Mahdi, Figma engineering blog, April 2017). The Redis pages are the official command reference. Quoted phrases are short attributed quotations; everything else is described in our words.