🚀 New! Kestra raises $3 million to grow Learn more

EachParallel EachParallel

yaml
type: "io.kestra.core.tasks.flows.EachParallel"

For each value in the list, execute one or more tasks in parallel.

The list of tasks will be executed for each item in parallel. The value must be a valid JSON string representing an array, e.g. a list of strings ["value1", "value2"] or a list of dictionaries [{"key": "value1"}, {"key": "value2"}]. You can access the current iteration value using the variable null.

The task list will be executed in parallel for each item. For example, if you have a list with 3 elements and 2 tasks defined in the list of tasks, all 6 tasks will be computed in parallel without any order guarantee.

If you want to execute a group of sequential tasks for each value in parallel, you can wrap the list of tasks with the Sequential task. If your list of values is large, you can limit the number of concurrent tasks using the concurrent property.

We highly recommend triggering a subflow for each value instead of specifying many tasks wrapped in a Sequential task. This allows much better scalability and modularity. Check the flow best practices documentation and the following Blueprint for more details.

Examples

yaml
id: "each_parallel"
type: "io.kestra.core.tasks.flows.EachParallel"
value: '["value 1", "value 2", "value 3"]'
tasks:
  - id: each-value
    type: io.kestra.core.tasks.debugs.Return
    format: "{{ task.id }} with current value '{{ taskrun.value }}'"
yaml
id: "each_parallel"
type: "io.kestra.core.tasks.flows.EachParallel"
value: 
- value 1
- value 2
- value 3
tasks:
  - id: each-value
    type: io.kestra.core.tasks.debugs.Return
    format: "{{ task.id }} with current value '{{ taskrun.value }}'"

Handling each value in parallel but only 1 child task for each value at the same time.

yaml
id: "each_parallel"
type: "io.kestra.core.tasks.flows.EachParallel"
value: '["value 1", "value 2", "value 3"]'
tasks:
  - id: seq
    type: io.kestra.core.tasks.flows.Sequential
    tasks:
    - id: t1
      type: io.kestra.plugin.scripts.shell.Commands
      commands:
        - 'echo "{{task.id}} > {{ parents[0].taskrun.value }}
        - 'sleep 1'
    - id: t2
      type: io.kestra.plugin.scripts.shell.Commands
      commands:
        - 'echo "{{task.id}} > {{ parents[0].taskrun.value }}
        - 'sleep 1'

Properties

concurrent

  • Type: integer
  • Dynamic:
  • Required: ✔️
  • Default: 0

Number of concurrent parallel tasks

If the value is 0, no limit exist and all the tasks will start at the same time

tasks

  • Type: array
  • SubType: Task
  • Dynamic:
  • Required: ✔️
  • Min items: 1

value

  • Type:stringarray
  • Dynamic: ✔️
  • Required: ✔️

The list of values for this task

The value car be passed as a String, a list of String, or a list of objects

errors

  • Type: array
  • SubType: Task
  • Dynamic:
  • Required:

List of tasks to run if any tasks failed on this FlowableTask