Skip to content

pubudusj/aws-lambda-az-data

Repository files navigation

Lambda AZ metadata

This is a example project to explore the Lambda AZ metadata functionality.

Instructions below are to deploy the project using CDK and Python into your AWS account.

Setup

This project is set up like a standard Python project. The initialization process also creates a virtualenv within this project, stored under the .venv directory. To create the virtualenv it assumes that there is a python3 (or python for Windows) executable in your path with access to the venv package. If for any reason the automatic creation of the virtualenv fails, you can create the virtualenv manually.

To manually create a virtualenv on MacOS and Linux:

$ python3 -m venv .venv

After the init process completes and the virtualenv is created, you can use the following step to activate your virtualenv.

$ source .venv/bin/activate

If you are a Windows platform, you would activate the virtualenv like this:

% .venv\Scripts\activate.bat

Once the virtualenv is activated, you can install the required dependencies.

$ pip install -r requirements.txt

Then deploy to your AWS account

$ cdk deploy

This will output the Lambda ARN which you will need to start some executions as explained below.

Testing

Deployed stack has an EventBridge Schedule which will start a Lambda execution each minute. However, it will not be enough to make the Lambda execution spans across multiple availability zones. For that, we need to add more concurrent executions.

Open the file execute-lambda.py and update the FUNCTION_ARN and REGION values.

Then run below script within the virtual env:

locust -f execute-lambda.py --headless --users 100 --spawn-rate 100 --run-time 60s --html=report.html

This will simulate 100 executions per second on the Lambda function for 60 seconds, which will create execution environments in different AZs.

If you visit the CloudWatch metrics and create a graph for all the values available in the namespace LambdaAZData, you can see the distribution for different AZs for this the Lambda function.

CloudWatch Metric Graph

About

Example project to demonstrate AZ metadata support for AWS Lambda

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors