---
title: 'Setting Workflow-Level Concurrency Limits with max_concurrency'
date: '2026-12-02T08:27:03+07:00'
description: '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.'
author: 'AI Assistant'
image: 'https://blog.redlinesoft.net/images/post/adk-workflow-max-concurrency-limits.jpg'
alt: 'Parallel workflow branches flowing through a funnel that limits how many run at once'
tags: ['google-adk', 'adk-2-0', 'workflows', 'concurrency', 'parallel-execution', 'graph-workflows']
---

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, and `JoinNode` ([graph routes](https://adk.dev/graphs/routes/))
- Some familiarity with [dynamic workflows](https://adk.dev/graphs/dynamic/) 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 `RetryConfig` exists 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](https://github.com/google/adk-python/blob/main/src/google/adk/workflow/_workflow.py)):

- **`max_concurrency: int | None = None`** — the maximum number of **parallel graph-scheduled nodes**. `None` or any value `<= 0` means 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.

```python
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](https://adk.dev/workflows/) or [retries](https://adk.dev/graphs/retry/) 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](https://adk.dev/graphs/dynamic/) recommend the built-in parallel worker over a hand-rolled `asyncio.gather` precisely because it "performs the fan-out and bounds concurrency":

```python
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_workers` **must be >= 1** — a lower value raises `WorkflowConfigurationError`.
- It can **only be set when `parallel_worker=True`** — same error otherwise.
- Python's default is `None` (unlimited). The TypeScript SDK's `node(worker, {parallelWorker: true, maxParallelWorkers: 4})` **defaults to 8**, and Go's `workflow.NewParallelWorker(name, child, maxConcurrency, ...)` takes `0` for 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](https://adk.dev/graphs/retry/) share the same budget:

- **A node waiting out its backoff delay is still an active node.** A policy with `max_attempts=5` and `initial_delay=1.0` keeps a failing node in flight across waits of 1, 2, 4, and 8 seconds — during which it holds one of your `max_concurrency` slots. 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.0` spreads retries so that a burst of failures does not wake up on the same tick and consume every slot simultaneously.
- **Timeouts free slots.** A `timeout` on 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_concurrency` slots × `max_attempts` retries × 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=4` and 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 `Workflow` sets `max_concurrency` deliberately — not by leaving it at `None` in production.
- [ ] List-processing steps use the built-in `parallel_worker` instead of a raw `asyncio.gather` when a bound is wanted.
- [ ] `max_parallel_workers >= 1` and only set alongside `parallel_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_concurrency` is 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.

## References

- https://adk.dev/workflows/
- https://adk.dev/graphs/dynamic/
- https://adk.dev/graphs/retry/
- https://github.com/google/adk-python
