Batching Executions
When you need to process many Workflow executions at once, the async execution endpoint is ideal for batch processing. Async executions automatically queue when you exceed your concurrency limit, allowing you to initiate many executions quickly without waiting for each one to complete.
Why Use Async Execution for Batch Jobs
Async execution is perfect for batch processing scenarios because:
- Automatic queuing: Executions automatically queue when you exceed your concurrency limit
- Non-blocking: You can initiate many executions quickly without waiting for completion
- Efficient resource usage: Executions process as capacity becomes available
- Scalable: Handle large batches without overwhelming your system
Basic Batch Job Pattern
The simplest pattern is to initiate all executions at once. They’ll queue automatically if needed:
Tracking Batch Job Completion
After initiating your batch, you have several options for tracking completion:
Option 1: Webhooks (Recommended)
The most efficient approach is to use webhooks to receive completion notifications. See our Long Running Workflows guide for webhook setup details.
Option 2: Status Polling
Poll the status endpoint to check completion. This is useful when you need to wait for results before proceeding:
Option 3: Hybrid Approach
Initiate executions and periodically check status, but rely on webhooks for final notification:
Best Practices
Use External IDs for Tracking
Always include an external_id when initiating batch executions. This allows you to correlate webhook events with your internal records, making it easy to track which item in your batch corresponds to each execution.
Monitor Concurrency Limits
Be aware of your organization’s concurrency limits. While async executions queue automatically, understanding your limits helps you plan batch sizes and processing times.
Handle Failures Gracefully
Some executions in a batch may fail. Use webhooks or status polling to identify failures and implement retry logic or error handling as needed.
Use Webhooks for Large Batches
For large batches (hundreds or thousands of executions), webhooks are more efficient than polling. They reduce API calls and provide real-time notifications.
Batch Size Considerations
There’s no hard limit on batch size, but consider:
- Your organization’s concurrency limits
- Processing time per execution
- Webhook endpoint capacity
- Error handling complexity
Related Documentation
- Long Running Workflows - Detailed guide on async execution patterns
- Webhooks Configuration - Set up webhooks for completion notifications
- API Reference - Execute Workflow Async
- API Reference - Check Workflow Execution Status