BeginnerCoder

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.

Want it another way?
Task

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.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.

Keep going with DevOps Foundations

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.