Design Per-Firm Token Quotas and Rate Limits for Model Calls
Last updated: November 29, 2026
Quick Overview
Design a service that enforces per-customer, per-user, and per-feature limits on LLM token usage and request rates across many model providers, while keeping latency low and giving accurate usage reporting.
Harvey
November 29, 20260
0
0 solved
Design a service that enforces per-customer, per-user, and per-feature limits on LLM token usage and request rates across many model providers, while keeping latency low and giving accurate usage reporting.
Harvey serves large firms whose usage is spiky (a whole practice group running a review workflow at once) while depending on upstream model capacity it does not fully control. The interviewer wants token-aware limiting, a split between hard upstream limits and contractual quotas, and graceful degradation rather than hard failures.
What the Interviewer Expects
- Distinguish request rate limits from token budgets and from contract quotas
- Estimate tokens before the call and reconcile after
- Use a fast shared store such as Redis with atomic scripts
- Protect shared upstream capacity with a global limiter
- Define behavior on limit: queue, downgrade, or reject with a clear message
- Record usage durably for billing and admin dashboards
Key Topics to Cover
How to Approach This
- Start by clarifying functional and non-functional requirements with the interviewer.
- Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
- Draw a high-level architecture first, then deep dive into 1-2 critical components.
- Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
- Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
- How do you stop one firm's bulk workflow from starving interactive chat for others?
- What happens if Redis is unavailable?
- How would you let an admin set limits per practice group?
- How do you handle streaming responses whose length is unknown upfront?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Limits at several scopes: provider and model (upstream tokens per minute), tenant (contracted monthly tokens and burst rate), user (abuse protection), and feature (bulk workflows vs chat). Check overh...
High-Level Design
An LLM gateway sits in front of every model call. For each request it: estimates tokens (prompt tokens counted exactly, completion capped by max_tokens), calls the limiter to reserve from ev...