API Throttle Manager
Snowflake interview questions · Medium · Coding round · 6 tests
Design an APIThrottleManager for an API gateway. A request is accepted only if it
passes every active rate-limit rule.
Interface
type ThrottleRule = {
windowSeconds: number;
maxCalls: number;
};
class APIThrottleManager {
constructor(rules: ThrottleRule[]);
addRule(rule: ThrottleRule): void;
allowRequest(timestamp: number): boolean;
}
Rules
Run your code with Ctrl+Enter to see results.