It‘s not only Lamda
Economics behind serverless
by Christian Bannes and Vadym Kazulkin, ip.labs GmbH
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
Money for
nothing
Developers are good guys
They can ignore money...
Image: https://www.flickr.com/photos/pictures-of-money/17121925920/
Cloud changes things
Lambda settings
It‘s not only
Lamda…
...also consider the infrastructure
Image: https://stocksnap.io
You also need…
• Storage
• Databases
• Queues
• Api Gateway
• Logging
• Data Transfer
• And More ...
Image: https://stocksnap.io
Most expensive…
...are people
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 512MB
• Each lambda takes 200ms
• 0.5GB * 0.2sec * 1Mio
= 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
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
$ 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
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
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
• Cost for compute is always higher
• For serverless you need right workload and architecture
• For constantly high workloads it can quickly become
expensive
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
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/reactive
• API-driven
• Batch Job
• ML/AI
• Big Data
Image: flickr.com/photos/everywhereatonce/294789504
Understand your workloads
• Do we need to access specialized
hardware ?
• GPU access required?
• 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 shared between all functions
packed on the same VM
• Do functions need to communicate
with each other?
• functions 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
• Invocation duration/ Timeouts
• Lambda 15min
• API Gateway integration 29sec
• Max Memory
• Lambda 3GB
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
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
• Lambda 3000 per 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 imposed by other dependencies
6. Organizational knowledge
Understand the operational constraints
imposed by other dependencies
• Language runtime choice
• Can be forced by some dependencies to
other libraries
• Relation database choice
• Aurora Serverless: either use VPC or use
Data API
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?
• Are the developers willing to
learn new languages?
Future of Serverless
Simon Wardley https://twitter.com/swardley/status/1017074876887322627
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
• Improve security
• Accommodate cost-performance
“A Berkeley View on Serverless Computing” https://www2.eecs.berkeley.edu/Pubs/TechRpts/2019/EECS-2019-3.html
Predictions
• More available runtimes (e.g. GraalVM)
• Platform limitations will be weakened or
disappear
• New use cases of serverless (Big Data,
ML/AI)
• Access to specialized hardware
• Companies gaining advantages from the
FinDev approach
Image: Marco Verch via Flickr (Creative Commons 2.0)
https://www.flickr.com/photos/30478819@N08/26528539689/
Serverless vs VM
• "Pay as you go" can significantly reduce
server cost because you don’t pay for ide
time
• Cost for compute is always higher
• For serverless you need right workload and
architecture
• For constantly high workloads it can quickly
become expensive
• Application lifecycle
• Workloads
• Platform limitations
• Cost at scale
• Operational constraints
• Organizational knowledge
FaaS or not to FaaS
Thank You!

"It’s not only Lambda! Economics behind Serverless" at Serverless Architecture Conference April 2019 by Christian Bannes and Vadym Kazulkin (both ip.labs GmbH)