Lesson 24 — Sliding-window rate limiter
Count only recent calls
A fixed window limiter ("100 per minute, counter resets at :00") lets a client do 100 calls at 0:59 and 100 more at 1:00. A sliding window keeps the timestamps of recent calls and, on each request, forgets those older than the window. If fewer than max remain, the call is allowed.
events = events.filter((e) => e.time > cutoff);
Why it matters: sliding windows give a precise, fair limit at any moment.
At the top of the returned function, drop timestamps older than the window with filter.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.
Ready for more? Optional paid resources that pick up where this lesson leaves off.
Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.
Project-based DevOps Foundations courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for DevOps Foundations books — check the publication year so the examples match current versions.
Search Amazon →