https://www.boundaryml.com logo
rate limiting
# general
b
how are ppl managing rate limit issues for gemini or any other model? I am hitting 1M token/min thing rate limit even with 10 parallel workers. This is with 2.5-flash. what can be done to mitigate this for production? where number of simulataneous workers wud be 100/thousands to begin with. any best practices how ppl are doing it in production? I knw there are exponentiall backoff etc but that doesn't help mitigte all this. Any link/resource to run in production around this would be very helpful
b
Have you reached out to your GCP account rep to ask for a quota increase?
It sounds like you have more traffic than you have capacity for, in which case you really just need to get more capacity - either on GCP or by looking into other hosting providers
If we're talking more transient rate limiting / demand provisioning, then you'll probably want to start looking into task queue systems (in GCP this is Cloud Tasks, but there are other alternatives out there; for more LLM-native scenarios there are things like OpenAI's batch API)
Exponential backoff is one of many stateless strategies for smoothing errors resulting from traffic spikes, but only works presuming there's enough capacity to handle the overall magnitude of traffic coming into your system
If you want to share more details about what you're doing, happy to talk through something that would work more specifically for you
b
I am using AI Studio. Haven’t gone to vertex ai (GCP) yet. I am runnning 10 parallel workers each with around 30 text content that passes through a bunch of LLM calls. Around 6-7 LLM calls per text content so 300 text content * 6 LLM calls. All ten have around 30 such content distributed running in mutliprocessing.Pool
b
Something like this then, perhaps? https://redis.io/glossary/rate-limiting/
You’d bump the counter per worker based on estimated token count and then decrement on completion. It would possibly need periodic resets to account for worker failure.
b
I think we might be making it too complicated. There should be ways how one can have LLMs without rate limiting issue. Have tried back off etc. tokens per min rate limited
b
The simplest solution is getting more capacity (either with AI studio, Vertex, or another provider); it’s also the only one that will work if you want to scale 10-100x
If you have multiple workers, you either need a static per-worker rate limiter (maybe this works for you, but at 10 workers you’re capped at 100k toks/min ea, and at 1000 workers this is is 1k tokens/min) or a dynamic one (Redis, task queues, etc)