Lesson 15 — Rate limiting
A limit per client
A rate limiter must count per client, not for everyone together — otherwise one noisy user blocks all the others. Keep a Map from client id (an API key or IP address) to their count.
visits.set(page, (visits.get(page) || 0) + 1);
Note: real DevOps tools (CI servers, load balancers, Docker, Kubernetes) cannot run in your browser, so this exercise is a small plain-JS simulation of the logic those tools use. Gateways like Nginx and Cloudflare do this for you in production.
Why it matters: fair limits stop one abuser without hurting normal users.
Count calls per client id: increase its count, and return "blocked" once the count is above max.
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.