This question evaluates understanding of precise sliding-window rate limiting, multi-dimensional counters, time-series state management, and distributed systems concerns such as sharding, clock skew, idempotency, and scalable state eviction.
You are designing a rate limiter for an API that must enforce a true sliding-window limit (i.e., at any instant, only the last T seconds of traffic count toward the quota). You will first design a global limiter, then extend it to multi-dimensional limits.
Design and implement a precise sliding-window rate limiter that enforces a cap of R requests within any rolling T-second window (true sliding window; not fixed window or token bucket). Specify:
Each request includes two attributes: userId and userExperience.
Enforce all of the following limits concurrently:
Explain key design choices:
Login required