rate limiting
Sliding Window Log
Store every request timestamp — 100% accurate, no boundary problem
Active in Window0 / 6
Total Logged0
Allowed0
Rejected0
6 req / 5s sliding window
// timestamp log
No requests yet. Click "Send Request" to begin.
// how it works
Store a sorted list of timestamps for each client. On each request:
- Filter out timestamps older than (now − windowSize)
- Count remaining timestamps
- If count < limit → allow and add current timestamp
- If count ≥ limit → reject
// trade-offs
- 100% accurate — no boundary problem
- Simple and intuitive mental model
- O(n) memory — stores every timestamp
- Memory intensive for high-traffic APIs
- Cleanup overhead on each request