AO
Back
Google Common Problems

Design a Rate Limiter for AI Output Tokens

System DesigneasyLast reported October 2026
By AceOffer · Updated October 2026 · Reported 2× across 111 reports

Understanding the Problem

Design a rate limiter that controls the billing tokens AI agents consume. Two L5 onsite reports name it: one calls it a variant of the classic rate limiter and answered with a token bucket (that loop passed); the other says the tokens are output tokens, so you must handle the last request when there are not enough tokens left, and that nothing else about the round was special. No report gives scale, other follow-ups, or how the last-request question was answered.

Functional Requirements

Structured requirements coming soon. For now, see the full problem statement above and the deep-dive prompts below.

Non-Functional Requirements

Latency, throughput, availability, consistency targets — being authored.

The Set Up

Defining the Core Entities

Core entities (Request, Batch, Worker, Cache, etc.) — being authored.

The API

POST /endpoint → describe request shape GET /endpoint → describe response shape (API spec being authored)

High-Level Design

Component diagram + walkthrough mapping each functional requirement to a system flow — being authored.

Potential Deep Dives

These are the directions the interviewer is likely to push you. Each one has multiple valid solutions at different quality tiers.

1)What do you do with the last request when the bucket may not have enough tokens for its output? (when: reported, one L5 onsite: the limit is on output tokens)

Bad

Naive approach with serious trade-off — being authored.

Good

Solid baseline with reasonable trade-offs — being authored.

Great

Production-grade approach with explicit trade-off rationale — being authored.

What is Expected at Each Level?

L4 / Mid-level

Cover happy path. Clarify scope. Identify the obvious bottleneck. Pick a reasonable storage and reasonable scaling approach.

L5 / SeniorTarget

All of the above plus: explicit failure handling, durability vs latency trade-offs, choose the right batching/caching strategy, articulate why.

L6 / Staff+

All of the above plus: organizational concerns (rollout, migration, on-call), quantitative analysis, multi-region considerations, what could go wrong with the proposed solution at 10x scale.

Insider Notes

Interviewer hints: One report says the limit is on output tokens, so you have to handle the last request when the bucket cannot cover it; it says nothing else about the round was special. The other names only the prompt and that it answered with a token bucket. No other interviewer probe is reported.

Edge cases to test (ours): a request whose output is larger than what is left; several requests from one agent in flight at once; a long idle gap (refill must stop at capacity); output size only known after generation.

Alternative approaches (ours): Leaky bucket (smooths traffic to a constant rate; less burst-tolerant, and a poor fit for requests whose size varies by thousands of tokens); Fixed window counter (simple; allows up to twice the rate at window edges); Sliding window log (exact, but stores every event; heavy at high request rates)

Prepping for Google with friends?

Send them this page. It is free to read, no account needed.

More Google Questions

Free preview

Every question in the Google catalog gets this depth

What you just read — canonical solution, follow-up arc, what passing candidates actually did — exists for all 48 Google questions, refreshed monthly from new candidate reports.

$59/mo — or $50/mo with the 3-month pass · cancel anytime
Google · System Design · Last reported October 2026
Is this helpful?