Rate Limiting, Throttling and Quota Management Questions

Protecting API capacity and enforcing fair use: rate-limiting algorithms (token bucket, leaky bucket, fixed/sliding window), per-client quotas, throttling responses (429 semantics, Retry-After), and tiered plan enforcement. Covers where to enforce limits (gateway vs. service), distributed counters, and graceful degradation under load.

HardTechnical
97 practiced

Implement a TokenBucket rate limiter in JavaScript with the following characteristics: a maximum capacity (burst), refill rate (tokens per second), and methods tryRemove(count) which returns true/false immediately and remove(count) which returns a Promise that resolves when tokens become available. Ensure the implementation scales to many concurrent callers efficiently without creating many timers.

MediumTechnical
96 practiced

Implement a rate-limited wrapper in JavaScript:

function rateLimit(fn, maxCalls, perMilliseconds)

The wrapper should return a function that ensures fn is invoked at most maxCalls times per perMilliseconds window. Calls beyond the limit must be queued and executed as capacity becomes available. Preserve this and arguments for fn. Provide a browser-friendly implementation and discuss trade-offs between sliding-window and token-bucket approaches.

That is every published Rate Limiting, Throttling and Quota Management question for Frontend Developer so far. Browse the other topics in this category, or practice this one interactively.