Menu

Six workers, one OpenAI key, and 78 wasted calls: sharing a token budget in Redis
📰

Six workers, one OpenAI key, and 78 wasted calls: sharing a token budget in Redis

DEV Community: redis·Krrish Kumar·1 day ago
#aKXgorpM
#devtoredis#devto#dev#limit#tokens
Reading 0:00
15s threshold

If you call an LLM API from more than one process, you've probably seen this: each worker has a polite little rate limiter, each worker stays under the limit, and you still get a wall of 429 Too Many Requests .

The reason is simple. The provider's limit belongs to your API key , but each limiter only counts its own calls. Six workers that each allow the full limit can send six times the limit together.

This post walks through the fix: one shared budget in Redis that counts requests and tokens, checked in one atomic step. At the end there's a small open-source package, llm-pacer , that does it for you.

Tokens per minute is the limit that hurts

OpenAI, Anthropic and most other providers enforce at least two limits at once:

RPM : requests per minute

TPM : tokens per minute (prompt plus completion)

They also send headers such as x-ratelimit-remaining-tokens and, on a 429, retry-after-ms .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.