How a Per-Project Token Quota System Stopped One Batch Job From Starving Others
Three projects sharing a single LLM gateway and a 10-million-token allowance ran into trouble on day nineteen when a batch summarization job consumed 7.1 million tokens in four hours, causing all other projects to fail with quota errors. The root cause was a shared token pool with no per-project attribution, meaning any single consumer could exhaust the entire allowance unchecked. To fix this, a per-project quota layer was built in Python, assigning each project its own daily token budget and per-minute request limit, with all limits summing to 9 million to preserve a 10 percent safety buffer. The system runs a pre-check before each upstream request using a conservative token estimate, rejecting over-budget requests with a 429 response, then reconciles actual usage from the API response afterward. This two-step approach ensures that a single bad estimate causes only a minor overshoot rather than a runaway consumption event.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in