Setting Workflow-Level Concurrency Limits with max_concurrency
Bound parallel node execution in ADK with the Workflow max_concurrency field and node-level max_parallel_workers, and see how limits interact with retries and rate limits.
Published on • December 2, 2026
AI Assistant

Fan-out is the moment a workflow stops being a pipeline and starts being a load generator. Three parallel research branches are fine; thirty are a burst of simultaneous model calls that lands on your provider’s rate limiter, and three hundred is an outage you caused yourself — queued requests, 429s, exhausted connection pools, and a retry policy that multiplies the stampede it was meant to absorb.
ADK 2.0 gives you concurrency controls at two levels: a workflow-level max_concurrency on the Workflow itself that throttles how many graph-scheduled nodes run at once, and node-level max_parallel_workers on a parallel worker that bounds how many items a single fan-out processes concurrently. In this tutorial you will learn why limits matter, what each knob actually does (including what it deliberately does not throttle), how they interact with retries, and what sensible values look like.
Prerequisites
- ADK 2.0 (
pip install google-adk) - Graph workflow basics:
Workflow, fan-out edges, andJoinNode(graph routes) - Some familiarity with dynamic workflows and
ctx.run_node()
1. Why concurrency limits matter
A graph workflow’s scheduler runs ready nodes as their triggers arrive — parallel branches from START, multiple JoinNode predecessors, sibling nodes released together. Without a bound, the width of your fan-out is your request rate:
- Rate limits. Model APIs bill and throttle by requests per minute. An unbounded fan-out of thirty agent nodes converts one user action into thirty simultaneous calls — and a burst is exactly what triggers 429 responses.
- Resource exhaustion. Every in-flight node holds connections, memory, and worker attention. Unbounded parallelism exhausts the pool before it finishes the work.
- Retry amplification. Failed nodes retry. Retries while siblings still run compound the load on an already-struggling service — the classic thundering herd that jitter in
RetryConfigexists to break up, but only if the herd is not infinitely large to begin with.
A limit turns “as fast as the graph allows” into “as fast as my budget and providers allow.”
2. Workflow-level: max_concurrency
The Workflow class carries a max_concurrency field. Its documented semantics (verified in the adk-python source):
max_concurrency: int | None = None— the maximum number of parallel graph-scheduled nodes.Noneor any value<= 0means unlimited.- It only applies to nodes triggered by graph edges. Dynamic nodes invoked via
ctx.run_node()are excluded — they are awaited inline by their parent, and throttling them would deadlock the orchestrator waiting on its own child. - The scheduler buffers rather than drops. When the limit is reached, ready nodes wait in the trigger buffer and start as slots free up; nothing is discarded.
- Replayed nodes do not consume slots. Nodes fast-forwarding from checkpoint history are not counted, so a resume after a pause cannot starve real work behind phantom activations.
from google.adk import Workflow
root_agent = Workflow(
name="research_workflow",
max_concurrency=4, # at most 4 graph-scheduled nodes in flight
edges=[
("START", research_A, gather),
("START", research_B, gather),
("START", research_C, gather),
("START", research_D, gather),
(gather, synthesize),
],
)
Here four research branches are declared, but only four run concurrently — and because the scheduler also serializes repeated triggers of the same node, a node never runs against itself while a previous activation is still in flight.
One important honesty note: max_concurrency appears on the Workflow model in the ADK Python source, but it is not yet covered on the workflows or retries doc pages — those document the related knobs below. Treat the source docstring as the specification, and pin your ADK version accordingly.
3. Node-level: bounded parallel workers
The second control bounds a single fan-out over a list. The dynamic workflows docs recommend the built-in parallel worker over a hand-rolled asyncio.gather precisely because it “performs the fan-out and bounds concurrency”:
from google.adk import Context, Workflow
from google.adk.workflow import node
@node
def analyze_item(node_input: str):
"""Processes a single item."""
return f"done {node_input}"
worker = node(
analyze_item,
parallel_worker=True,
max_parallel_workers=4, # at most 4 items in flight
)
@node(rerun_on_resume=True)
async def supervisor(ctx: Context, node_input: list[str]):
"""Runs the worker over the whole list; it fans out internally."""
return await ctx.run_node(worker, node_input)
The worker takes a list input, runs the wrapped node once per element, and collects the results. Key validation rules from the source:
max_parallel_workersmust be >= 1 — a lower value raisesWorkflowConfigurationError.- It can only be set when
parallel_worker=True— same error otherwise. - Python’s default is
None(unlimited). The TypeScript SDK’snode(worker, {parallelWorker: true, maxParallelWorkers: 4})defaults to 8, and Go’sworkflow.NewParallelWorker(name, child, maxConcurrency, ...)takes0for unlimited — so check the default for your language before assuming a bound exists.
Manual fan-out (asyncio.gather over ctx.run_node coroutines) remains available for custom scheduling or partial-failure handling — but it has no built-in bound. If you need one there, you must add it yourself (a asyncio.Semaphore), and on resume only failed or interrupted workers re-execute either way.
4. Workflow-level versus node-level: which one where
Workflow(max_concurrency=...) | node(..., max_parallel_workers=...) | |
|---|---|---|
| Bounds | Everything the graph schedules | One worker’s item fan-out |
| Scope | Whole workflow run | A single node’s execution |
| Default | None — unlimited | None — unlimited (Python) |
| Counts | Edge-triggered nodes in flight | Concurrent child tasks of the worker |
| Use when | The whole graph must respect a global budget | One step processes a long list |
They compose: max_concurrency=4 caps the graph globally, while a worker with max_parallel_workers=2 ensures no single fan-out step can consume all four slots on its own. Set the workflow-level limit as your provider-facing budget, and the worker-level limit as your “how wide should this one step go” decision.
5. Interaction with retries and timeouts
Concurrency and retry policy share the same budget:
- A node waiting out its backoff delay is still an active node. A policy with
max_attempts=5andinitial_delay=1.0keeps a failing node in flight across waits of 1, 2, 4, and 8 seconds — during which it holds one of yourmax_concurrencyslots. Tight limits plus aggressive retries can stall a graph: the scheduler stops starting buffered nodes while failed ones wait to retry. - Jitter is your ally here. The default
jitter=1.0spreads retries so that a burst of failures does not wake up on the same tick and consume every slot simultaneously. - Timeouts free slots. A
timeouton a hung attempt converts an indefinitely-occupied slot into a failure that either retries with a bounded wait or releases the node — the reason to give every remote-calling node a timeout when you run with tight concurrency. - Beware the worst case. Practical ceiling:
max_concurrencyslots ×max_attemptsretries × loop iterations. Size the limit against that product, not against the happy path.
6. Practical values
There is no universal number, but these starting points hold up:
- Model-call-heavy graphs: 2–8. Most consumer-tier Gemini rate limits tolerate single-digit concurrent streams per project comfortably. Start at
max_concurrency=4and raise it only when your observability shows headroom. - Tool- or I/O-heavy nodes: higher. If the parallel work is database queries or HTTP calls to your own services, the bound is your connection pool size — set the limit at or below it.
- One worker per long list: 4–8 items. The TypeScript default of 8 is a sane cross-language reference; drop to 2–4 when each item is itself an LLM call.
- Respect the provider’s RPM, not just concurrency. Concurrency bounds simultaneous requests; rate limits count requests per minute. With retries enabled, keep some RPM headroom for the retries you know will happen.
A good workflow makes its limits visible: log ctx.attempt_count, watch queue depth when the scheduler starts buffering, and treat a persistent buffer as the signal to either widen the limit (if the provider allows) or narrow the fan-out (if it does not).
7. Checklist
- Every fan-out-heavy
Workflowsetsmax_concurrencydeliberately — not by leaving it atNonein production. - List-processing steps use the built-in
parallel_workerinstead of a rawasyncio.gatherwhen a bound is wanted. -
max_parallel_workers >= 1and only set alongsideparallel_worker=True. - Remote-calling nodes have timeouts, so stuck attempts release their slots.
- Retry backoff uses the default jitter so failed nodes do not re-enter in lockstep.
- The budget accounts for retries × loop rounds, not just the happy path.
- The ADK version in use is pinned, since
max_concurrencyis specified by source rather than the doc pages.
Concurrency limits are not a performance footnote — they are the difference between a fan-out and a flood. Declare the budget at the workflow level, bound the wide steps at the node level, and let retries spend the budget on recovery instead of amplification.