Chuyển tới nội dung chính

Flow concurrency

A flow can limit how many of its executions run at the same time. When a new execution would exceed the limit, it waits in the Queued state and starts when a running one finishes. Use it to protect a source or a destination that cannot take parallel runs, for example a flow that rewrites one table.

Set a limit​

Add a concurrency block to the flow:

id: my-flow
namespace: company.team
concurrency:
limit: 2 # max concurrent executions of this flow (>= 1)
behavior: QUEUE # what to do when at the limit (default QUEUE)
tasks:
- id: hello
type: io.kestra.plugin.core.log.Log
message: Hello from egret
KeyWhat it does
limitThe most executions of this flow that may run at once. Must be 1 or more.
behaviorWhat happens to a new execution when the flow is at its limit. Default QUEUE.

The limit is per flow: each flow has its own count, and a subflow's executions count against the subflow's own flow, not the parent's.

What happens at the limit​

  1. A flow with limit: 2 already has two executions that are not finished (any non-terminal state).
  2. You start a third one: manually, from a schedule, from a webhook or from a flow trigger.
  3. The new execution is held in the QUEUED state. No task runs.
  4. When one of the running executions ends, the oldest queued execution is promoted and runs.

So queued executions start in the order they were created. A queued execution shows a Queued state chip in the executions list and on its detail page. To see what is waiting, filter the list by the Queued state.

Behaviors​

behaviorStatus
QUEUEA new execution over the limit is held in QUEUED until a slot frees. The default.
CANCELA new execution over the limit is set to CANCELLED at once, without running.
FAILA new execution over the limit is set to FAILED at once, without running.

All three behaviors are enforced. A CANCELLED or FAILED over-limit execution is terminal at once — it runs no task and holds no slot — and still fires the usual end hooks (flow triggers, alerts). You can also act on a QUEUED execution by hand: see unqueue and force-run.

Limits and known issues​

  • The limit applies to every way an execution of the flow starts — a scheduled, manual, webhook or flow-trigger run, a replay or restart, and a subflow child — and each obeys the flow's behavior (QUEUE holds it QUEUED, CANCEL/FAIL makes it terminal at once). A subflow child is gated on its own flow's limit, not the parent's.
  • A self-referential subflow can stall. A flow that starts itself as a Subflow with wait: true, under a limit lower than its recursion depth, can deadlock: the parent holds a slot while it waits, and the child it spawned sits QUEUED forever because no slot frees. Use unqueue or force-run to break it, or raise the limit.
  • One edge: a restart that reopens a Loop over a QUEUE limit runs at once rather than queuing — queuing it would lose the restart of its failing iteration — so it can briefly take the flow one over its limit.
  • limit below 1 is refused when you save.

Further reading​