Skip to content

Concurrent For Loop

Executes a loop body concurrently for a range of numbers.

This node iterates from First Index to Last Index (inclusive) and executes the Body branch for each number in the range.

The key feature is its ability to run iterations in parallel, which can significantly speed up workflows that involve many independent, repeated operations.

Concurrency#

The level of parallelism is controlled by Worker Count: - Worker Count > 0: A fixed number of workers will process the loop iterations concurrently. For example, with 100 iterations and 4 workers, each worker will handle roughly 25 iterations. - Worker Count = 0: The node will attempt to run all iterations simultaneously, creating a separate worker for each one. This provides maximum parallelism but can be resource-intensive. Use with caution for large ranges. - Global Concurrency Disabled: If concurrency is disabled in the application settings, this node will behave like a standard, sequential for-loop, processing one iteration at a time, regardless of the Worker Count setting.

Execution Flow#

  1. The loop starts when the exec input is triggered.
  2. Iterations are distributed among the available workers.
  3. The Completed output is executed only after all iterations have finished successfully.
  4. If an error occurs in any iteration, the node will cancel all other running and pending iterations. The error will be propagated, and the Completed branch will not be executed.

Inputs#

Port Description
Starts the loop execution.
First Index
The starting number for the loop (inclusive).
Last Index
The ending number for the loop (inclusive).
Worker Count
Number of parallel workers. Set to 0 for maximum concurrency. Runs sequentially if global concurrency is off.

Outputs#

Port Description
Body
Executes for each iteration of the loop.
Index
The current iteration number.
Completed
Executes once all iterations have completed without error.

ID: core/concurrent-for-loop@v1