Skip to content

aws-samples/lambda-with-multithreading

Implementing parallel data processing within AWS Lambda execution environment

This sample project illustrates parallelization techniques described in this blog.

Programming languages offer diverse techniques and terminology for parallel processing. Java employs multi-threading and thread pools. Node.js, though single-threaded, provides event loop and promises (for async programming), as well as worker threads (for actual multi-threading). Python supports both multi-threading (subject to Global Interpreter Lock) and multi-processing. Concurrent routines are another technique gaining attention in the industry.

This sample is provided for illustration purposes only and uses a language-agnostic term “worker” to denote a unit of parallel processing. Your specific parallelization implementation depends on your choice of runtime language and frameworks. We highly recommend you use battle-tested frameworks like Powertools for AWS Lambda that implement batch processing parallelization when possible. Regardless of the programming language, it is crucial to ensure all background threads/workers/promises/routines/tasks spawned by the function handler are completed within the same invocation before the handler returns.

Requirements

Deployment Instructions

  1. Create a new directory, navigate to that directory in a terminal and clone the GitHub repository:
    git clone https://github.com/aws-samples/lambda-with-multithreading
    
  2. Change directory to the pattern directory:
    cd lambda-with-multithreading
    
  3. From the command line, use AWS CDK to deploy the AWS resources for the pattern:
    cdk deploy
    
  4. Wait for CDK to complete the deployment.

Resources created as part of this sample deployment can have associated costs.

Cleanup

Delete the stack

cdk destroy

License

This library is licensed under the MIT-0 License. See the LICENSE file.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published