Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Your multi-tenant product routes all LLM traffic through a shared gateway, and one tenant's batch scripts keep starving everyone else. Design per-tenant rate limiting: decide what you meter, where you enforce it, and what a throttled tenant experiences.
Meter tokens and concurrency per tenant at the gateway. Reserve estimated input tokens, debit output tokens mid-stream. Return 429 with Retry-After. Keep a global guard under the provider's own limits.
Picture a buffet where one customer keeps loading a wheelbarrow while everyone else holds a plate. Counting trips through the line does not fix it because the wheelbarrow customer only goes once. You have to weigh the food on the way in. That is what tokens are for an LLM gateway: the right unit to count. Every customer gets a daily food budget by weight, and the door scale weighs the load before it goes onto the plate and again as more gets piled on. When a customer hits their weight cap, the door politely says "come back in twenty minutes" with a clear note about how full their bucket is. Above all customers, the kitchen has its own daily limit so no one customer plus a busy day can break the kitchen for everyone.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
8 min: why tokens (and concurrency) beat requests, the reserve debit settle lifecycle at the gateway, 429 semantics and headers, tiered degradation paths, the global guard that mirrors the upstream provider's limits, observability.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Metering requests per second only. A tenant sending one 200k-token prompt per second uses 200 times the GPU of a tenant sending 100-token prompts, but the RPS counter says they are equal.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.