Rate-Limit Connector Calls Per Tenant and Target System
Last updated: November 29, 2026
Quick Overview
Implement a limiter that allows at most N calls per sliding window of W seconds for each (tenant, connector) pair, such as Acme's calls into ServiceNow, and reports how long a rejected caller should wait before retrying.
Moveworks
November 29, 20260
0
0 solved
Implement a limiter that allows at most N calls per sliding window of W seconds for each (tenant, connector) pair, such as Acme's calls into ServiceNow, and reports how long a rejected caller should wait before retrying.
An assistant platform calls customers' ServiceNow, Jira, Okta and Workday instances, each with its own API quota, and one noisy tenant or bulk sync must not exhaust another's budget. The interviewer looks for an exact sliding-window design, a correct retry-after computation, and awareness of how this changes when distributed.
What the Interviewer Expects
- Keys state by (tenant, connector) to isolate tenants
- Implements an exact sliding window, not fixed buckets
- Evicts expired timestamps lazily on each call
- Computes retry-after from the oldest timestamp that must expire
- Discusses memory and the distributed version
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
- Memory is too high at 10k calls per window; what approximation would you use?
- How would you implement this across 50 API pods sharing one quota?
- The target returns 429 with its own Retry-After; how do you reconcile that with your limiter?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
allow(tenant, connector, now) returns True and records the call if fewer than limit accepted calls happened in (now - W, now]; otherwise False. retry_after returns seconds until a slot frees. ...
High-Level Design
Sliding-window log: a deque of accepted timestamps per key. On each call, pop timestamps that fell out of the window, then compare length to limit. Rejected calls are not recorded, so a client hammeri...