Examples
Parallel Execution

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 steps
  • fan-out-fan-in.ts - Shows the fan-out/fan-in pattern for data processing
  • parallel-with-dependencies.ts - Implements parallel execution with dependencies
  • error-handling-parallel.ts - Demonstrates error handling in parallel execution
  • run-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.ts

Expected Output

The example will:

  1. Execute multiple independent steps in parallel
  2. Show performance improvements over sequential execution
  3. Demonstrate fan-out/fan-in for data processing
  4. Handle errors in parallel execution
  5. 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