Contact v.kazulkin@iplabs.de Vadym Kazulkin ip.labs GmbH - - PowerPoint PPT Presentation
Contact v.kazulkin@iplabs.de Vadym Kazulkin ip.labs GmbH - - PowerPoint PPT Presentation
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...
Contact
Vadym Kazulkin
ip.labs GmbH
v.kazulkin@iplabs.de xing.com/profile/Vadym_Kazulkin @VKazulkin @ServerlessBonn (Meetup)
Christian Bannes
ip.labs GmbH
c.bannes@iplabs.de xing.com/profile/Christian_Bannes
Ip.labs GmbH
To FaaS... …or not to FaaS
Image: https://aws.amazon.com/de/lambda/features
Function as a Service = AWS Lambda
Image: https://aws.amazon.com/de/lambda/features
Serverless is more than Function as a Service
Image: https://www.infoq.com/articles/serverless-sea-change/
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
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
- Lambda with 512MiB
- Each lambda takes 200ms
0.5 GiB * 0.2 sec * 1 Mio = 100 000 GB-Seconds
Requests:
$0.20
GB-Seconds:
$1.67
Cost scales linearly with memory
How does this compare to VM pricing model?
Lambda performance compares to
- M4 (general purpose)
- M5 (general purpose)
EC2 Instance Families
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
Image: https://aws.amazon.com
AWS monetizes the datacenter… … by selling time on their servers
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
- f your total cost
$ 3.50
Per million API calls Api Gateway
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
- perate 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
Image: https://twitter.com
Switch to "On-Demand"
Example
$2400 / Month $520 / Month 100 API requests per second 24/7
- API Gateway
- Lambda with 1GB and
300ms per request
- Load balancer
- 3 x M5.xlarge with
16GB each
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
Forrest Brazeal „The Business Case For Serverless” https://www.trek10.com/blog/business-case-for-serverless/
No Infrastructure Maintanence Auto Scaling Built in Fewer Engineers Required Lower Technical Debt Focus on Business Value & Innovation Faster Time to Market
Do more with (Server-)less
FaaS... …or not to FaaS ?
Image: https://stock.adobe.com
- 1. Application lifecycle
- 2. Workloads
- 3. Platform limitations
- 4. Cost at scale
- 5. Operational constraints
- 6. Organizational knowledge
Decision Checklist
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
Image: burst.shopify.com/photos/a-look-across-the-landscape-with-view-of-the-sea
Serverless is a perfect fit
Exploit phase
- Built something that does
provide customer value
- Build it on scale
- Build a profitable product
around it
Image: Robert Scoble via Flickr
partly serverless and partly not serverless architecture
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
“A Berkeley View on Serverless Computing” https://www2.eecs.berkeley.edu/Pubs/TechRpts/2019/EECS-2019-3.html
Latency Scaling Pricing Consistency
S3 Storage TradeOffs
“A Berkeley View on Serverless Computing” https://www2.eecs.berkeley.edu/Pubs/TechRpts/2019/EECS-2019-3.html
Latency Scaling Pricing Consistency
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/
Lambda in VPC
As your function scales, be mindful of several issues:
- Managing the IP address space in your
subnets
- Reaching the account level network
interface limit
- The potential to hit the API rate limit on
creating new network interfaces
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/
NEW: Lambda in VPC:
Leveraging AWS Hyperplane to provide NAT capabilities from the Lambda VPC to customer VPCs
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/
NEW: Lambda in VPC:
- The network interface creation happens
when Lambda function is created or its VPC settings are updated.
- Because the network interfaces are shared
across execution environments, only a handful of network interfaces are required per function
- Function scaling is no longer directly tied to
the number of network interfaces
- Hyperplane ENIs can scale to support
large numbers of concurrent function executions
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/
Amazon Aurora Serverless Data API as beta for MySql available
https://docs.aws.amazon.com/de_de/AmazonRDS/latest/AuroraUserGuide/data-api.html
Don‘t be scared
- f cold starts
To avoid cold starts them completely, you have to :
- Overpay
- Overprovision
Cold starts don’t really matter if the you make the call asynchronously
Understand platform limitations
- Cold start
- Lambda with and without VPC for
each runtime
- Invocation duration/timeouts
- Lambda 15min
- API Gateway integration 29sec
- Max Memory
- Lambda 3GB
Understand platform limitations
- Max concurrent invocations
- 1000-3000 parallel executions for
all Lambdas in each AWS account
- Scaling thresholds
- Dynamo DB provisioned and on-
demand capacities
- 1. Application lifecycle
- 2. Workloads
- 3. Platform limitations
- 4. Cost at scale
- 5. Operational constraints imposed by other dependencies
- 6. Organizational knowledge
Understand your cost at scale
- Lambda
- API Gateway
- Dynamo DB capacity choices
- Remote API calls
- Logging costs
- Monitoring costs
- 1. Application lifecycle
- 2. Workloads
- 3. Platform limitations
- 4. Cost at scale
- 5. Operational constraints
- 6. Organizational knowledge
Understand the operational constraints (imposed by other dependencies)
- Language runtime choice
- Can be forced by some dependencies to
- ther libraries
Yan Cui „Not so FaaS” https://blog.binaris.com/not-so-faas/
- 1. Application lifecycle
- 2. Workloads
- 3. Platform limitations
- 4. Cost at scale
- 5. Operational constraints imposed by other dependencies
- 6. Organizational knowledge
Understand organizational knowledge
- Do you already have
DevOps knowledge?
Tom McLaughlin Talk: What do we do when the server goes away?
- Monitoring & Alerting
- Chaos Engineering & Game Days
- Infrastructure as Code & Testing
- Help understand constraints
- f AWS services & choose the right
- ne
Tom McLaughlin „What do we do when the server goes away” https://speakerdeck.com/tmclaugh/serverless-devops-what-do-we-do-when-the-server-goes-away
Understand organizational knowledge
- Do you already have
DevOps knowledge?
- Are the developers willing to
learn new languages?
Future of Serverless
Berkeley View on Serverless Computing
“A Berkeley View on Serverless Computing” https://www2.eecs.berkeley.edu/Pubs/TechRpts/2019/EECS-2019-3.html
Berkeley View on Serverless Computing
- Provide low latency and high IOPS
Serverless Ephemeral Storage
- Provide Serverless Durable Storage
- Improve Networking and Performance
- Improve Security
- Accommodate cost-performance
“A Berkeley View on Serverless Computing” https://www2.eecs.berkeley.edu/Pubs/TechRpts/2019/EECS-2019-3.html
- Application lifecycle
- Workloads
- Platform limitations
- Cost at scale
- Operational constraints
- Organizational knowledge