◉GEMINI LABJP
●ARGON — gemini-4-argon is generally available as of 10/13, aimed at complex coding, agents, math and science●DEEP RES — deep-research-pro-preview-12-2025 shuts down 10/23, 6 days left. Move to deep-research-preview-04-2026●NANO — gemini-nano-banana-2.1 is GA (10/06). gemini-3.1-flash-image is deprecated with no shutdown date yet●MCP — One write-up cut an 85,000-token tool result to 310 tokens by wrapping it in an ADK FunctionTool●FLASH — gemini-3.7-flash and 3.5-flash now route automatically to newer Flash models (10/08)●NEW — Stop Re-Reading Every Crash Report: Gre…●ARGON — gemini-4-argon is generally available as of 10/13, aimed at complex coding, agents, math and science●DEEP RES — deep-research-pro-preview-12-2025 shuts down 10/23, 6 days left. Move to deep-research-preview-04-2026●NANO — gemini-nano-banana-2.1 is GA (10/06). gemini-3.1-flash-image is deprecated with no shutdown date yet●MCP — One write-up cut an 85,000-token tool result to 310 tokens by wrapping it in an ADK FunctionTool●FLASH — gemini-3.7-flash and 3.5-flash now route automatically to newer Flash models (10/08)●NEW — Stop Re-Reading Every Crash Report: Gre…
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 API249ConcurrencyRate LimitingBulk ProcessingProduction33Architecture10

✦ 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.

✦

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-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.
◈ API / SDK2026-07-27
Retiring Prompt Assets That Refuse to Die — A Ledger for Paths Static Analysis Cannot See
A prompt I had supposedly consolidated away was still running daily. Here is the retirement ledger I built to cross-check static references, flag defaults, observation windows, model end-of-life dates, and cache effectiveness.
◈ API / SDK2026-05-21
Designing Event-Driven AI Workflows with Gemini API and Cloud Pub/Sub — Notes from an Indie Developer
An implementation memo on wiring Gemini API into Cloud Pub/Sub event-driven workflows. Using an app-review analysis pipeline as the running example, the article covers retry policy, dead-lettering, idempotency, and cost guardrails — from the perspective of someone running it solo.