Lambda
Lambda
Trung Dang,
Solutions Architect, Amazon Web Services
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Comparison of operational responsibility
AWS manages Customer manages
More opinionated
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
The high-level view
AWS Services
Event Databases
Etc.
Lambda
Function
Python
Javascript
Java
Golang
C#
BYOL
© 2021, Amazon Web Services, Inc. or its Affiliates.
Container images
The customer view
AWS Lambda
Alias: prod Alias: stage
Code Config
Zip + Layers 20%
Event Container Image 80% 100%
Source
and more
Mapping Execution Execution
Environments Environments
Version 1 Version 2
IAM or Lambda
or
Permissions IAM Execution
Functions Role
and more
microVM microVM
Event Execution Execution
Source Environment Environment
Mapping
Frontend
and more
and more
Event
Source
Mapping
Frontend
Sync
Internal
Async queue
event
event
response
internal
queue
Frontend
Sync microVM
Execution
or Environment
and more
Frontend
microVM
Execution
Internal Environment
or
Async queue
and more
microVM
Event Execution
Source Environment
Mapping
Frontend
and more
Workers
microVM microVM
Execution Execution
Environment Environment
microVM microVM
Execution Execution
Environment Environment
Invoke
Invoke
Invoke
Invoke
Invoke
Initialization Shutdown
Environment
Execution
Invoke
Invoke
Initialization Shutdown
time
Execution Environment
Execution Environment
Lambda Extensions
(Optional)
Execution Environment
Lambda Extensions
(Optional)
Execution Environment
Runtime API
Container Image
Function Code
Extensions (Optional)
Execution
Environments
Lambda functions
Same VPC
are not deployed
Config in your VPC.
Different
VPC Config
Execution
Environments
More memory
=
more CPU resources
https://github.com/alexcasalboni/aws-lambda-
power-tuning
Why Arm64?
Up to 19% better performance, and
Two architecture options: 20% lower cost.
Provisioned concurrency:
• Pre-warm execution environments
to reduce cold start impact.
• Burst to standard concurrency if
need be.
Reserved concurrency:
• Maximum concurrency for a given
function.
• Also reserves that concurrency
from the account quota.
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What is Lambda Insights?
Monitor, troubleshoot, and optimize the performance of AWS Lambda functions
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Multi-Function Dashboard
• Aggregated view across multiple Lambda
functions
• Search by “name” (“tag” upcoming) to focus
on a specific or a subset of Lambda
functions
• Understand how compute, memory
allocation, and function duration changes
over a period of time to help optimize
Lambda function utilization
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Single-Function Dashboard
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Single-Function Dashboard
• Number of requests
• Duration (in GB-s) 100ms with 2GB of RAM
costs the same as
Free Tier 200ms with 1GB of RAM
1M requests and 400,000 GB-sec of
compute.
Every month, every customer.
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Orchestration for serverless apps
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Step Functions
Easily coordinate multiple Lambda functions using visual workflows
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Service integrations with Step Functions
Amazon Simple AWS Step Functions Amazon Simple Amazon SageMaker AWS Glue
Notification Service Queue Service
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Serverless Application
Model
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Serverless Application Model (AWS SAM)
• Serverless framework for applications
• Two components:
• AWS SAM template specification
• AWS SAM CLI
• Benefits:
• Single deployment configuration
• Extension of CloudFormation
• Local debugging and testing
• Built-in best practices and development
tool integration
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS SAM: Less complexity, more power
ListTable:
Type: AWS::Serverless::SimpleTable
• Bucket management
• ‘sam deploy’ command
• Uploads application resources
• Requests a CloudFormation change set
• ‘sam build’ command provides best practice build processes
• Built In – JavaScript, Python, Java, Ruby, Go, .NET
• Convenient for building in containers, and packaging for AWS Lambda
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lambda Layers: Uses cases
Upload image to registry 1. Pull image from Amazon ECR Ready for invoke
2. Optimize image
3. Deploy image to Lambda
Container image security
Container images are stored in Amazon Elastic Container Registry (ECR)
Amazon ECR provides several mechanisms for security and controlling access to
container images:
Amazon Elastic
Container Registry
Lambda extensions
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
What are Lambda extensions?
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Use cases
• Integrate AWS Lambda with your favorite monitoring, observability,
security, and governance tools
• Capture diagnostic information before, during, and after function
invocation
• Fetch configuration settings or secrets before the function’s
invocation
• Detect and alert on function activity through hardened security
agents, which can run as separate processes from the function
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Extensions available today
AW S L A M B DA R E A DY PA R T N E R , AW S PA R T N E R , A N D AW S TO O L S U S I N G L A M B D A E X T E N S I O N S
How to deploy extensions
Bootstrap
• Lambda starts any extensions found in the /opt/extensions/ directory
Important quotas
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Picking a Compute Platform: Containers vs. Lambda
10 GB
© 2021, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Useful resources