Parallel execution of operations with AWS Lambda durable functions

AWS Lambda durable functions

Demonstrates parallel execution of operations using Lambda durable functions with batch result collection and error handling

This pattern demonstrates parallel execution capabilities of AWS Lambda durable functions by performing four mathematical operations concurrently.
The workflow uses context.parallel() to execute addition, subtraction, multiplication, and division operations simultaneously on two input numbers.
Each operation is defined as a separate step with its own logging and error handling, showcasing the durable execution model.
The division operation uses a custom retry strategy (RetryPresets.none()) to prevent retries on division by zero errors.
Results from all parallel operations are collected using BatchResult, which tracks both successful results and failure counts.
If any operation fails, the workflow returns an error response; otherwise, it returns all calculation results in a structured JSON format.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/lambda-durable-parallel-execution-python-sam

Deploy

sam buildsam deploy --guided


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: sam delete.

Created by:

Anup Rajpara

Anup Rajpara

Anup is passionate about serverless & event-driven architectures.

Follow on LinkedIn

Sahil Bhimjiani

Sahil Bhimjiani

Sahil Bhimjiani is a Solutions Architect at Amazon Web Services.

Follow on LinkedIn