The ForEach activity in ADF allows you to iterate over a collection and perform certain actions for each item in the collection. When you enable parallel execution, the ForEach activity can process multiple items in the collection concurrently, which can significantly improve the performance of your pipeline, especially when dealing with large collections.
- Isolation of Iterations: When you run iterations in parallel, each iteration is isolated from the others. This means that the setting of a variable within one iteration will not affect the value of the variable in another iteration if the variable is defined within the scope of the ForEach loop. However, if you are using global variables (variables defined outside the ForEach activity), you need to be careful as concurrent modifications to these variables can lead to unexpected behaviors.
To avoid conflicts with variables when running in parallel, ensure that you either:
- Use local variables within the scope of each iteration, or
- If you must use global variables, manage access to these variables carefully, for instance, by using them in a read-only manner within the ForEach or by employing mechanisms to ensure that only one iteration can modify the variable at a time, though this latter approach can negate some benefits of parallel processing.
In the settings of the ForEach activity, you can specify the "Batch Count," which determines how many iterations can run in parallel. This allows you to control the degree of parallelism according to the capabilities of your environment and the requirements of your process.
Since you are using item().myparam
to access the parameters for each iteration, each iteration will inherently work with its specific set of data fetched from the Lookup activity.