AWS Lambda - 2020 - 0316-SRV - Slide-Deck PDF
AWS Lambda - 2020 - 0316-SRV - Slide-Deck PDF
AWS Lambda - 2020 - 0316-SRV - Slide-Deck PDF
James Beswick
Senior Developer Advocate, AWS Serverless
@jbesw
© 2020, Amazon Web Services, Inc. or its Affiliates.
About me
• James Beswick
• Email: jbeswick@amazon.com
• Twitter: @jbesw
• Senior Developer Advocate – AWS Serverless
• Self-confessed serverless geek
• Software Developer
• Product Manager
• Previously:
• Multiple start-up tech guy
• Rackspace, USAA, Morgan Stanley, J P Morgan
Your function
Language
runtime
Execution
environment
Lambda
service
Compute
substrate
Your function
Language
runtime
Execution
environment
Lambda
service
Compute
substrate
// Python // Node.js
Start new
Download Execution Execute Execute
your code environment INIT code handler code
Service
identifies if
Request made
warm execution
to Lambda’s API
environments is
available
Yes
Complete
Invoke handler
invocation
Service
identifies if Find available
Request made Download
warm execution compute
to Lambda’s API No customer code
environments is resource
available
The facts:
• <1% of production workloads
• Varies from <100ms to >1s
Be aware…
• You cannot target warm
environments
• Pinging functions to keep them
warm is limited
Influenced by:
• Memory allocation
• Size of function package
• How often a function is called
• Internal algorithms
The facts:
• Code run before handler Dependencies,
• Used to initialize objects, configuration
establish connections, etc. information
• Biggest impact on cold-starts
Also occurs when…
• A new execution environment
is run for the first time
• Scaling up
Function
Find available
configured with Download
compute
Provisioned customer code
resource
Concurrency
Start execution
Execute INIT
environment
Service
identifies if
Request made
warm execution
to Lambda’s API This becomes the default for all
environment is
available provisioned concurrency
Yes
execution environments
Complete
Invoke handler
invocation
Things to know:
• We provision more than you request.
• We still reap these environments.
• There is less CPU burst than On-Demand during init
Memory 👉 Power
Features:
• Data-driven cost and
performance optimization for
AWS Lambda
• Available as an AWS Serverless
Application Repository app
• Easy to integrate with CI/CD
https://github.com/alexcasalboni/aws-lambda-power-tuning
© 2020, Amazon Web Services, Inc. or its Affiliates.
Meet AWS Lambda Power Tuning
https://github.com/alexcasalboni/aws-lambda-power-tuning
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS Lambda Power Tuning (input)
Lowest costs
https://github.com/alexcasalboni/aws-lambda-power-tuning
© 2020, Amazon Web Services, Inc. or its Affiliates.
Real-world examples
https://github.com/alexcasalboni/aws-lambda-power-tuning
© 2020, Amazon Web Services, Inc. or its Affiliates.
How billing rounding impacts cost optimization
Example 1 Example 2
import boto3
S3_client = None
ddb_client = None
Externalize orchestration
Avoid idle/sleep – delegate to Step Functions
Synchronous: Asynchronous:
• The caller is waiting • The caller receives ack quickly
• Waiting incurs cost • Minimizes cost of waiting
• Downstream slowdown affects • Queueing separates fast and
entire process slow processes
• Process change is complex • Process change is easy
• Dependent on custom code • Uses manages services