Lambda
Learn how Sedai uniquely optimizes AWS serverless functions to achieve your performance and cost goals.
Sedai optimizes two key aspects of AWS Lambdas:
Memory Allocation
Autonomous Concurrency
Memory Allocation
Sedai only supports Autopilot mode for optimizing Lambda memory. The system is confident it can safely make gradual changes without disrupting the function's performance.
We recommend creating a group of Lambdas to try out Autopilot and explore the feature.
Sedai profiles serverless functions and determines optimal memory configurations based on reinforcement learning. Optimizations typically yield faster and cheaper results.
You can define specific goals to guide how the system optimizes functions.
Autonomous Concurrency
In order to use this feature, additional setup is required.
This feature helps eliminate cold starts with marginal impact on cloud spend. Using a combination of the following, Sedai informs its central control and learning unit to manage Lambda cold starts:
Sedai AV Lambda Extension (external extension written in Go): Analyzes Lambda behavior such as runtime events, cold start duration, and concurrency patterns (this allows close Lambda monitoring without any overhead)
Traffic Seasonality: Monitors and builds a seasonality model in order to understand local and global trends and anticipate traffic fluctuations
Provisioned Concurrency: Monitors concurrency events as well as concurrency scaling based on seasonality
Supported Runtimes
NodeJS 12 and above on
x86_64Python 3.7 and above on
x86_64Java 8 and above on
x86_64
The static and runtime characteristics of the extension are limited to:
Additional 12 MB size in deployed Lambda layer
0.1 ms latency overhead per 1,000 invocations
0.11 ms execution time overhead per 1,000 invocations
Setup
The AV Lambda extension acts as Sedai's control center for your Lambdas. It is responsible for collecting metrics from Sedai's autonomous concurrency extensions and communicating with Sedai core components.
Deploy the AV Lambda extension manually or via your preferred IaC tool:
AWS Cloud Development Kit (CDK)
1. Set up app directory:
2. Download and extract .zip file:
3. Install CDK cli:
4. Initialize CDK environment
5. Deploy using CDK
This will take a few minutes. CDK and CloudFormation Stack will provision the IAM Roles, DynamoDB and the Lambda Function on your AWS Account. You can view the progress in CloudFormation > Stacks > sedai-avlambda-stack.
AWS CloudFormation
1. Set up app directory:
2. Download and extract zip file:
3. Download the CloudFormation template file:
4. Change "/path/to/AVLambdaGo" to actual path of AVLambdaGo binary in the cloudformation.yml extracted in Step 2
"/path/to/AVLambdaGo" to actual path of AVLambdaGo binary in the cloudformation.yml extracted in Step 25. Create S3 bucket to store AVLambdaGo artifact
6. Create CloudFormation template with AVLambdaGo artifact URI (from S3 bucket in Step 4) to final.yml
7. Deploy CloudFormation Stack from final.yml
This will take a few minutes. CloudFormation will provision the IAM Roles, DynamoDB and the Lambda Function on your AWS Account. You can view the progress in CloudFormation > Stacks > sedai-avlambda-stack.
Serverless Framework
Before you get started, please make sure you install Serverless Framework 3 and configure AWS Credentials as recommended.
1. Set up app directory:
2. Download and extract zip file:
3. Download the serverless.yaml template file:
4. Install serverless (sls) cli-
serverless (sls) cli-You can skip this step if it is already installed.
Add the following to ~/.bashrc or ~/.profile:
5. Install serverless-dynamodb-autoscaling plugin for sls
serverless-dynamodb-autoscaling plugin for sls6. Run sls deploy to deploy the AV Lambda function on your AWS account:
sls deploy to deploy the AV Lambda function on your AWS account:This will take a few minutes. Serverless Framework will provision the IAM Roles, DynamoDB and the Lambda Function on your AWS Account.
Manual Setup
In this method, you will log into your AWS account in order to manually provision AWS Lambda and associated resources.
⚠️ In order to complete setup, you must have permission within your AWS account to provision Lambda functions, DynamoDB Tables, and IAM Roles.
1. Set up DynamoDB Table
Navigate to your DynamoDB Console and select Create Table; enter the following details to provision a new DynamoDB table for the AV Lambda backend:
Table Name: SedaiResourceConcurrencyStats
Partition Key:
resourceId,StringSettings: Custom Settings
Read/write Capacity Settings: Provisioned
Autoscaling:
ONfor Read and Write (use default values)Encryption at Rest: Use default KMS-based encryption
Tags: Optional (add per your organization's policy for creating new tables)
2. Set up IAM Role for Lambda Functions
In this step you will grant access for the DynamoDB table to invoke Lambda functions:
Navigate to IAM Console > Roles and select Create Role. Select AWS Service as your trusted entity and choose Lambda as the use case.
Select Next to Add permissions, and click the Create Policy button. In the new window, toggle to the JSON editor tab.
Download a sample template from Sedai's repository and update the
<AWS-REGION>and<AWS-ACCOUNT-ID>placeholders in it, then paste the policy into the JSON editor. Select Next to optionally add tags, then Next to review the policy. Enter a unique name for the policy (such asiam-policy-sedai-avlambda-control-center) and select Create Policy to complete.From the Add permissions page, refresh the list and select the newly created IAM policy. Click Next and enter a unique name for the role (such as
iam-role-sedai-avlambda-control-center) and click on Create Role to finish setup.
3. Download .zip file
4. Create AV Lambda function
Go to the AWS Lambda console and select Create function.
Choose Author from scratch and name the function
Sedai-avlambda-control-center.For the runtime, select Go.1.x and choose x86_64 for the architecture.
Under the Permissions section, expand Change default execution role and select Use an existing role. Select the role created in the step 2.
Expand the Advanced Settings section and select Enable function URL; keep the default selection of AWS_IAM.
5. Share Lambda function URL with Sedai.
Please send the Lambda URL as well as your Sedai URL to [email protected].
Last updated
Was this helpful?

