Parallel Execution Example
This example demonstrates how to execute steps in parallel in ZoopFlow to improve performance and handle independent operations efficiently.
What You'll Learn
- How to execute multiple steps in parallel
- How to handle results from parallel executions
- How to implement fan-out/fan-in patterns
- How to manage errors in parallel execution
- How to optimize performance with parallel processing
Files in this Example
basic-parallel.ts- Demonstrates simple parallel execution of stepsfan-out-fan-in.ts- Shows the fan-out/fan-in pattern for data processingparallel-with-dependencies.ts- Implements parallel execution with dependencieserror-handling-parallel.ts- Demonstrates error handling in parallel executionrun-example.ts- Entry point to run the example
Parallel Execution Concepts
In ZoopFlow, parallel execution:
- Allows multiple steps to run concurrently
- Improves performance for independent operations
- Supports gathering results with Promise.all or Promise.allSettled
- Can implement sophisticated patterns like map-reduce
- Handles errors without stopping all parallel branches
How to Run
# From the project root
npm install
npx ts-node docs/new-structure/examples/parallel-execution/run-example.tsExpected Output
The example will:
- Execute multiple independent steps in parallel
- Show performance improvements over sequential execution
- Demonstrate fan-out/fan-in for data processing
- Handle errors in parallel execution
- Show how to manage dependencies between parallel branches
Output will include timing information and results from parallel executions.
Next Steps
- Implement parallel processing in your own workflows
- Combine parallel execution with conditional flows
- Explore more complex patterns like map-reduce
- Learn about distributed execution with Temporal in the Temporal Integration Example