About a year ago we embarked on our serverless journey building a platform which is 100% serverless. Serverless allowed us to move forward very fast, but at the same time, lack of documentation and best practices led us to take some wrong turns.
In this session, I’ll highlight the lessons I wish someone had taught me a year ago - from design patterns and dev methodologies to deployment and runtime.
6. COLD STARTS
Taken from: AWS re:Invent 2017: Become a Serverless Black Belt: Optimizing
Your Serverless Appli (SRV401)
https://www.youtube.com/watch?v=oQFORsso2go&feature=youtu.be&t=8m5s
DESIGN
a. Occurrence 0.2% (@chrismunns)
b. Impact up to 15 sec (!)
6
7. COLD STARTS RECOMMENDATIONS
DESIGN
Is it relevant to you?
7
Monitor & Alert
Remember new version impact
Keep Lambdas warm:
Reduce package size
Prefer Python / Node / Go over Java / .NET
Get Lambda out of VPC
8. DESIGN
Is it relevant to you?
Monitor
8
Remember new version impact
Keep Lambdas warm:
Reduce package size
Prefer Python / Node / Go over Java / .NET
Get Lambda out of VPC
COLD STARTS RECOMMENDATIONS
9. DESIGN
Is it relevant to you?
Monitor & Alert
New version impact
9
Keep Lambdas warm:
Reduce package size
Prefer Python / Node / Go over Java / .NET
Get Lambda out of VPC
COLD STARTS RECOMMENDATIONS
10. DESIGN
Is it relevant to you?
Monitor & Alert
Remember new version impact
Keep Lambdas warm
https://www.npmjs.com/package/lambda-warmer by @jeremyDaly or https://github.com/FidelLimited/serverless-plugin-warmup
10
Reduce package size
Prefer Python / Node / Go over Java / .NET
Get Lambdas out of VPC
COLD STARTS RECOMMENDATIONS
11. DESIGN
Is it relevant to you?
Monitor & Alert
Remember new version impact
Keep Lambdas warm:
Reduce packages
(use http://browserify.org/ or https://www.npmjs.com/package/serverless-plugin-optimize)
11
Prefer Python / Node / Go over Java / .NET
Get Lambda out of VPC
COLD STARTS RECOMMENDATIONS
http://bit.ly/ColdStartResearch
12. DESIGN
Is it relevant to you?
Monitor & Alert
Remember new version impact
Keep Lambdas warm:
Reduce package size
Prefer Python / Node / Go over Java / .NET
12
Get Lambda our of VPC
COLD STARTS RECOMMENDATIONS
13. DESIGN
Is it relevant to you?
Monitor & Alert
New version impact
Keep Lambdas warm:
Reduce package size
Prefer Python / Node / Go over Java / .NET
Get Lambdas out of VPC
13
COLD STARTS RECOMMENDATIONS
14. DESIGN
14
Get Lambdas out of VPC
Taken from: How to manage Lambda VPC cold starts and deal with that killer latency
https://medium.freecodecamp.org/lambda-vpc-cold-starts-a-latency-killer-
5408323278dd
17. DESIGN
LAMBDA CONCURRENCY
How to estimate?
Poll streamed-based
Concurrency = average execution duration * number of streams Amazon Kinesis
Data Streams
Amazon
DynamoDB
Poll non-stream-based (SQS)
Concurrency = average execution duration * Message batch
non-poll-based (S3, API GW)
Concurrency = average execution duration * invocations per second
Amazon Simple
Queue Service
Amazon Simple Storage
Service (S3)
Amazon API
Gateway
17
32. DEPLOY
32
Use canary gradual deployment
• API Gateway Canary Release
• Use weighted aliases and CodeDeploy.
• Beware of canary deployment of multiple functions
42. 7 Things
you need to know
before going serverless
Erez Berkner, CEO & Co-Founder
@erezberkner
Editor's Notes
Load test! (and remember ENI limitations for Lambda’s within the VPC)
Don’t load test in production! – set up a different account for dev and staging.
Monitor your concurrent executions and set up alert thresholds (“Concurrentexecutions” and “UnreservedConcurrentExecutions” metrics in CW)
Need more concurrency?
Reduce Lambda duration (e.g. increase Lambda resources)
Limit & Reserve the simultaneous execution of a specific Lambda
Consider other regions with higher concurrency limits
Open a ticket to AWS
Use Serverless deployment tools (Stackery/SLS framework/ SAM/CF) – don’t deploy / write code with AWS console
Use Serverless deployment tools (Stackery/SLS framework/ SAM/CF) – don’t deploy / write code with AWS console
Use Serverless deployment tools (Stackery/SLS framework/ SAM/CF) – don’t deploy / write code with AWS console