Skip to content

Add Lambda Durable Functions parallel processing pattern This pattern…#2949

Open
rssasidharan2 wants to merge 3 commits intoaws-samples:mainfrom
rssasidharan2:sasidhrn-lambda-durable-parallel-processing-nodejs
Open

Add Lambda Durable Functions parallel processing pattern This pattern…#2949
rssasidharan2 wants to merge 3 commits intoaws-samples:mainfrom
rssasidharan2:sasidhrn-lambda-durable-parallel-processing-nodejs

Conversation

@rssasidharan2
Copy link

Issue #, if available:

Description of changes:
Created new pattern to showcase lambda durable function - parallel processing use case in Node JS

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

… demonstrates parallel processing using AWS Lambda Durable Functions to execute multiple independent operations concurrently, achieving better performance improvement over sequential execution. Features: - Parallel execution with context.parallel() and child contexts - Automatic checkpointing and fault tolerance - Comprehensive error handling and validation - Human-readable logging with step indicators across all functions - Production-ready with structured logging - Complete test scenarios and documentation Implementation: - 1 orchestrator function coordinating parallel execution - 4 worker functions: inventory, payment, shipping, tax - Proper handling of parallel() return format (extracts from .all array) - Child context usage for isolated checkpoint management - Durable wait demonstration (1 second pause without compute charges) The pattern includes: - Complete SAM template with IAM permissions - Comprehensive README with deployment and testing instructions - Example test events and expected responses - Architecture documentation - Implementation details for parallel execution patterns
@bfreiberg
Copy link
Contributor

Please make sure to use the correct capitalization: It's Lambda durable functions not Lambda Durable Functions

@rssasidharan2
Copy link
Author

Made those capitalization changes. Please comment if any other changes needed.

@@ -0,0 +1,67 @@
{
"title": "Parallel Processing with AWS Lambda durable functions",
"description": "Order processing workflow using Lambda durable functions with parallel execution of multiple validation steps including inventory, payment, shipping, and tax calculations",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description should be <= 150 char length

{
"name": "Sasidharan Ramasamy",
"bio": "Technical Account Manager @ AWS with over 10 years of industry experience",
"linkedin": "https://www.linkedin.com/in/sasidharan-ramasamy/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the URL in this property, only include the ID to your LinkedIn profile.

@@ -0,0 +1,141 @@
# Submission Notes for lambda-durable-parallel-processing-sam
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this file for? Seems to be gen AI generated file.

- Effect: Allow
Action:
- lambda:InvokeFunction
Resource: '*'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make the policy more restrictive than '*'. Too much permission is provided.

Action:
- lambda:CheckpointDurableExecution
- lambda:GetDurableExecutionState
Resource: '*'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make the policy more restrictive than '*'. Too much permission is provided.


### Architecture

The solution consists of five Lambda functions:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you include an architecture diagram?


2. Change directory to the pattern directory:
```bash
cd lambda-durable-parallel-processing-sam
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cd serverless-patterns/lambda-durable-parallel-processing-sam


5. From the command line, use AWS SAM to deploy the AWS resources for the pattern as specified in the template.yml file:
```bash
sam deploy --guided
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy failed with the following error:

Error: Failed to create changeset for the stack: lambda-durable-fn, ex: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state: For expression "Status" we matched expected path: "FAILED" Status: FAILED. Reason: Requires capabilities : [CAPABILITY_NAMED_IAM]


Once you have run `sam deploy --guided` mode once and saved arguments to a configuration file (samconfig.toml), you can use `sam deploy` in future to use these defaults.

7. Note the outputs from the SAM deployment process. These contain the resource names and/or ARNs which are used for testing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deploy command outputs TestCommand. However, that command is not well formatted and throws error.


- [Lambda durable functions](https://docs.aws.amazon.com/lambda/latest/dg/durable-functions.html)
- [Durable Execution SDK for JavaScript](https://github.com/aws/aws-durable-execution-sdk-js)
- [Parallel Processing Patterns](https://docs.aws.amazon.com/lambda/latest/dg/durable-parallel.html)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link is forwarding to somewhere else now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants