Implement a Sliding Window Rate Limiter for Cloud API Calls
Last updated: December 9, 2025
Quick Overview
Implement a sliding window rate limiter that enforces per-tenant, per-cloud-provider API call limits. Support multiple time windows (per-second, per-minute, per-hour) simultaneously.
Wiz
December 9, 202513
6
2,169 solved
Implement a sliding window rate limiter that enforces per-tenant, per-cloud-provider API call limits. Support multiple time windows (per-second, per-minute, per-hour) simultaneously.
Wiz's scanning infrastructure makes millions of cloud API calls. Each cloud provider has rate limits, and exceeding them causes throttling that degrades scan performance for all tenants. A robust rate limiter ensures fair API usage across tenants while respecting provider limits. The interviewer evaluates your ability to design a clean, production-quality data structure.
What the Interviewer Expects
- Implement sliding window using sorted sets or circular buffers
- Support multi-dimensional limiting (per-tenant AND per-provider)
- Handle concurrent access safely
- Provide accurate rate information for backoff decisions
- Write clean, well-tested code
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you distribute this rate limiter across multiple scanning workers?
- What happens when a rate limit is hit? How should the caller handle it?
- How would you handle bursty traffic patterns?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Problem Analysis
In this problem, we need to implement a sliding window rate limiter that enforces API call limits based on multiple dimensions: per-tenant and per-cloud-provider. The sliding window algorithm is appro...
Approach
-
Data Structure: We will use a dictionary of sorted sets (or a circular buffer) for each tenant and cloud provider combination. Each sorted set will store timestamps of API calls.
-
**Add Cal...