GEMINI LABJP
NANOLITE — Nano Banana 2 Lite is here: Google's fastest and most cost-efficient Gemini Image model, made for running lightweight image generation cheaplyOMNIFLASH — Gemini Omni Flash is in public preview, a natively multimodal model that lets enterprises and developers build custom, dynamic video workflowsAGENTS — Managed Agents expand with background: true for async server-side runs and polling, remote MCP server integration, and refreshing credentials across interactionsMEMORY — The Memory Bank IngestEvents API is generally available, decoupling event ingestion from memory generation so you can stream content continuouslyTHROUGHPUT — Provisioned Throughput now lets you submit up to seven pending orders for the same model and regionDEPRECATE — Image generation models shut down on August 17, and the Grok 4.1 family on the Gemini Enterprise Agent Platform on August 20NANOLITE — Nano Banana 2 Lite is here: Google's fastest and most cost-efficient Gemini Image model, made for running lightweight image generation cheaplyOMNIFLASH — Gemini Omni Flash is in public preview, a natively multimodal model that lets enterprises and developers build custom, dynamic video workflowsAGENTS — Managed Agents expand with background: true for async server-side runs and polling, remote MCP server integration, and refreshing credentials across interactionsMEMORY — The Memory Bank IngestEvents API is generally available, decoupling event ingestion from memory generation so you can stream content continuouslyTHROUGHPUT — Provisioned Throughput now lets you submit up to seven pending orders for the same model and regionDEPRECATE — Image generation models shut down on August 17, and the Grok 4.1 family on the Gemini Enterprise Agent Platform on August 20
Articles/API / SDK
API / SDK/2026-05-31Advanced

Bulk Processing Without the 429s: Adaptive Concurrency for the Gemini API

Pushing tens of thousands of requests through the Gemini API with a fixed concurrency almost always produces 429s and dropped items. Here is an AIMD design that auto-tunes concurrency from the 429 feedback, with a bounded worker pool, a dead-letter queue, and resumable checkpoints.

Gemini API192Concurrency2Rate LimitingBulk ProcessingProduction32Architecture9

Premium Article

Bulk Processing Without the 429s: Adaptive Concurrency for the Gemini API

At two in the morning I was running a batch that classifies the user reviews of around forty wallpaper apps through the Gemini API. I have been building apps on my own since 2014, and review counts pile up quietly over the years. One night I tried to push about thirty thousand of them at once with concurrency set to 64, and the log turned red. 429 RESOURCE_EXHAUSTED came back again and again, and by morning nearly half of the items were still unprocessed.

When I dropped concurrency to 8 the 429s vanished, but now a full run took over an hour. Go fast and it breaks; play it safe and it crawls. As long as you try to move a large number of requests at a fixed concurrency, I think this is a wall everyone eventually hits. This article shares how to get past it by letting the concurrency tune itself in real time, following the code I actually run in production.

Why fixed concurrency does not work

The core problem with a fixed concurrency is that the rate the API will accept changes from moment to moment. Gemini quotas apply on both requests per minute (RPM) and tokens per minute (TPM), and the point where 429s start depends on other work in the same project and on how many tokens each request carries.

In other words, there is no such thing as a single "safe" concurrency. Some days a review is 50 tokens; other days a run of long reviews pushes each one to 2,000. A concurrency of 64 that felt comfortable in the first case instantly melts your TPM in the second. Tune for the heaviest moment and you are too slow; tune for the lightest and you break. Neither direction is optimal.

This is where AIMD (Additive Increase / Multiplicative Decrease), long used in network congestion control, earns its keep. While things go well you nudge the limit up; when you hit a 429 you cut it in half. You turn the very 429 the API returns into a sensor that finds the right concurrency for you.

How adaptive concurrency (AIMD) thinks

The behavior is almost embarrassingly simple. On a streak of successes, raise the limit by +1; on a 429, multiply the current value by 0.5. Repeat, and concurrency draws a sawtooth that tracks just under the live effective quota. Where a fixed value is one flat line, AIMD is a living line that rides up and down against the ceiling.

Three details matter in practice. First, a cooldown after a 429: if you start climbing again the instant you halve, the rebound walks you straight back into another 429, so you stay silent for a fixed period after any decrease. Second, a floor and a ceiling: below 1 the work stalls, and unbounded growth torches your TPM in a single burst. Third, never let non-429 errors (500/503/timeouts) trigger a decrease; those are transient faults, not quota overruns, and belong to retry logic, not to the concurrency knob.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
Understand why fixed concurrency causes both 429s and dropped items, and implement an AIMD scheme that auto-tunes concurrency from the 429 signal
Raise throughput safely with a bounded worker pool and a semaphore, and design a dead-letter queue plus resumable checkpoints that never lose work
See the measured breakdown of moving from fixed 64-way to adaptive control: completion time from 42 to 19 minutes and the 429 rate from 11% to 0.3%
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

API / SDK2026-06-26
When your Gemini API spend cap trips, paying users go down too — isolating the blast radius with per-tier projects
A Project Spend Cap stops the entire project at once. To keep a runaway free tier from taking paying users down with it, this is a design note on isolating the cap's blast radius across per-tier projects and closing the ~10-minute delay with an application-side soft budget gate.
API / SDK2026-05-19
Wiring Circuit Breakers and Graceful Degradation into Gemini API — an Indie App's Stability-First Notes
When you run Gemini API in production for an indie app, something upstream breaks at least a few times a month. Here are the building blocks for circuit breakers and graceful degradation I settled on, with the implementation traps I actually hit.
API / SDK2026-04-26
Architecting a Multi-Tenant SaaS on Gemini API — Tenant Isolation, Usage Metering, and Runaway Cost Defense in Production
A field-tested blueprint for serving Gemini API to multiple tenants on a single backend — covering tenant isolation choices, per-tenant rate limiting in Redis, request-level usage metering for billing, and runaway-cost defenses.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →