Contact v.kazulkin@iplabs.de Vadym Kazulkin ip.labs GmbH xing.com/profile/Vadym_Kazulkin @VKazulkin @ServerlessBonn (Meetup) Christian Bannes c.bannes@iplabs.de ip.labs GmbH xing.com/profile/Christian_Bannes
Ip.labs GmbH
To FaaS... …or not to FaaS
Function as a Service = AWS Lambda Image: https://aws.amazon.com/de/lambda/features
Serverless is more than Function as a Service Image: https://aws.amazon.com/de/lambda/features
Typical Three-Tier Image: https://www.infoq.com/articles/serverless-sea-change/
Function as a Service Image: https://www.infoq.com/articles/serverless-sea-change/
Serverless Applications Image: https://www.infoq.com/articles/serverless-sea-change/
Infrastructure cost Image: https://stocksnap.io
Velocity of your team Image: https://burst.shopify.com
What you really have to consider Total Cost of Ownership
Lambda pricing model
Cost for lambda REQUEST DURATION
Request Tier $ 0.20 Per 1 Mio Requests
Duration Tier $ 0.00001667 Per GB-Second
GB-Second ONE SECOND ONE GB
Example • 1 Mio requests Requests: • Lambda with 512MiB $0.20 • Each lambda takes 200ms GB-Seconds: 0.5 GiB * 0.2 sec * 1 Mio $1.67 = 100 000 GB-Seconds
Cost scales linearly with memory
How does this compare to VM pricing model?
EC2 Instance Families Lambda performance compares to • M4 (general purpose) • M5 (general purpose)
M5 General Purpose Instance Cost scales linearly with memory
Lamdba vs VM https://www.youtube.com/watch?v=b1ebYEfQX1s
Lambda compute is 5x more expensive than M5
Threading Model Idle Idle Pay per wall clock time Pay per use
AWS monetizes the datacenter… … by selling time on their servers Image: https://aws.amazon.com
Common pitfalls when working with lambda
More memory = more expensive?
Power tuning lambda • Executes different settings in parallel • Outputs the optimal setting Image: https://github.com/alexcasalboni/aws-lambda-power-tuning
Paying for wait time Image: https://blog.binaris.com/lambda-pricing-pitfalls/
The reality is… Lambda is often just a small percentage of your total cost
Api Gateway $ 3.50 Per million API calls
Event Sources • SQS and SNS are charged for requests • Kinesis charges for shard hours & PUT requests Image: https://blog.binaris.com/lambda-pricing-pitfalls/
Event Sources • Cost for Kinesis grows with slower rate • Attractive at to operate at scale Image: https://blog.binaris.com/lambda-pricing-pitfalls/
DynamoDB On-Demand Image: https://aws.amazon.com/blogs/aws/amazon-dynamodb-on-demand-no-capacity-planning-and-pay-per-request-pricing/
Provisioned vs On-Demand • Use On-Demand for spiky workloads • Use Provisioned for constantly high workload
Cost saving with On-Demand Switch to "On-Demand" Image: https://twitter.com
Example 100 API requests per second 24/7 • API Gateway • Load balancer • Lambda with 1GB and • 3 x M5.xlarge with 300ms per request 16GB each $2400 / Month $520 / Month
Serverless vs VM • "Pay as you go" can significantly reduce server cost because you don’t pay for ide time • For serverless you need right architecture • Consider the Total Cost of Ownership
What you really have to consider: Total Cost of Ownership
Ajay Nair (https://twitter.com/ajaynairthinks/status/1057696133076541441)
TCO Full Picture Auto Scaling Built in No Infrastructure Fewer Engineers Maintanence Required Faster Time to Lower Technical Market Debt Focus on Business Value & Innovation Forrest Brazeal „The Business Case For Serverless” https://www.trek10.com/blog/business-case-for-serverless/
Do more with (Server-)less
FaaS... … or not to FaaS ?
Image: https://stock.adobe.com
Decision Checklist 1. Application lifecycle 2. Workloads 3. Platform limitations 4. Cost at scale 5. Operational constraints 6. Organizational knowledge
Understand Application lifecycle Christian Posta „Be as serverless as you can, but not more than that” https://blog.christianposta.com/serverless/its-not-about-microservices-vs-serverless/
Explore phase • Quickly validate hypotheses • Rapidly experiment • Run experiments as cheaply as possible Serverless is a perfect fit Image: burst.shopify.com/photos/a-look-across-the-landscape-with-view-of-the-sea
Exploit phase • Built something that does provide customer value • Build it on scale • Build a profitable product around it partly serverless and partly not serverless architecture Image: Robert Scoble via Flickr
Application lifecycle • How much of my stack should I own to be able to deliver business value? • Outsource SLA, regulatory compliance, price, and roadmap to my service provider?
Existing applications • You can’t magically move that all off to service providers • You can try to modernize parts of them
Strangler Pattern • Add a proxy (API Gateway or Application Loadbalancer), which sits between the legacy application and the user • Add new services and link it to the proxy Marin Fowler „StrangerFigApplication” https://martinfowler.com/bliki/StranglerFigApplication.html
FinDev Concept Activity-based costing on a digital operation-by-operation basis • Figure out features which deliver business value comparing to their cost Aleksander Simovic & Mark Schwarz „FinDev and Serverless Microeconomics: Part 1” https://aws.amazon.com/de/blogs/enterprise-strategy/findev-and-serverless-microeconomics-part-1/
1. Application lifecycle 2. Workloads 3. Platform limitations 4. Cost at scale 5. Operational constraints imposed by other dependencies 6. Organizational knowledge
Understand your workloads • Event-driven • API-driven • Batch Job • ML/AI • Big Data Image: flickr.com/photos/everywhereatonce/294789504
Lambda Layers & Lambda Runtime API Door opener for use case like: • Big Data • ML/AI
Understand your workloads • Do we need to access specialized hardware ? • GPU access required? • Another RAM/CPU ratio? • Do we need constantly high performance? • Response time below 100 ms (e.g. bidding or gaming platforms) “A Berkeley View on Serverless Computing” https://www2.eecs.berkeley.edu/Pubs/TechRpts/2019/EECS-2019-3.html
Understand your workloads • Do we need high throughput ? • Lambda‘s network bandwidth is limited (an order of magnitude lower than a single modern SSD) shared between all functions packed on the same VM “A Berkeley View on Serverless Computing” https://www2.eecs.berkeley.edu/Pubs/TechRpts/2019/EECS-2019-3.html
Storage TradeOffs Scaling Pricing Latency Consistency “A Berkeley View on Serverless Computing” https://www2.eecs.berkeley.edu/Pubs/TechRpts/2019/EECS-2019-3.html
S3 Storage TradeOffs Scaling Pricing Latency Consistency “A Berkeley View on Serverless Computing” https://www2.eecs.berkeley.edu/Pubs/TechRpts/2019/EECS-2019-3.html
The State of Serverless Computing “Chenggang Wu & Vikram Sreekanti - The State of Serverless Computing” Craft Conference 2019 - Budapest , Hungary https://www.youtube.com/watch?v=htLQiSPMUmk&list=LLYgjRSI2oCzI9eooyFrWR7A&index=6
Understand your workloads • Do functions need to communicate with each other? • functions are not directly network accessible, they must communicate via an intermediary service “A Berkeley View on Serverless Computing” https://www2.eecs.berkeley.edu/Pubs/TechRpts/2019/EECS-2019-3.html
1. Application lifecycle 2. Workloads 3. Platform limitations 4. Cost at scale 5. Operational constraints imposed by other dependencies 6. Organizational knowledge
Understand platform limitations • Cold start • Lambda with and without VPC for each runtime
Ajay Nair „Become a Serverless Black Belt” https://www.youtube.com/watch?v=oQFORsso2go
Ajay Nair „Become a Serverless Black Belt” https://www.youtube.com/watch?v=oQFORsso2go
Lambda in VPC Chris Munns "Announcing improved VPC networking for AWS Lambda functions" https://aws.amazon.com/de/blogs/compute/announcing-improved-vpc-networking-for-aws-lambda-functions/
Lambda in VPC As function’s execution environment scales • More network interfaces are created and attached to the Lambda infrastructure. • The exact number of network interfaces created and attached is a factor of your function configuration and concurrency. Chris Munns: "Announcing improved VPC networking for AWS Lambda functions” https://aws.amazon.com/de/blogs/compute/announcing-improved-vpc-networking-for-aws-lambda-functions/
Recommend
More recommend