← Back
00:00

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

Idle