SERVERLESS
On cloud nine of scalability
WHOAMI
● Blogger https://breadcrumbscollector.tech
● Writing book on Clean Architecture in Python
● Twitter handle: @EnforcerPL
● Software developer with ~7 years experience
2/51
IoT Blockchain
Machine
Learning
Microservices
3/51
SERVERLESS
4/51
SERVERLESS
AWS Lambda
Google Cloud Functions
Azure Functions 5/51
SERVERLESS
AWS Lambda
Google Cloud Functions
Azure Functions
Serverless framework
6/51
SERVERLESS
AWS Lambda
Google Cloud Functions
Azure Functions
Serverless framework
Approach to development
7/51
SERVERLESS PRINCIPLES
● Write small functions with a single purpose
● ...
● ...
● ...
8/51
def add_blog_post(event, context):
# parse event data
# save some to database
return some_value
9/51
SERVERLESS PRINCIPLES
● Write small functions with a single purpose
● Run them on on-demand compute services
● ...
● ...
10/51
11/51
serverless_bill = f(time, assigned_ram, number_of_invocations)
12/51
13/51
SERVERLESS PRINCIPLES
● Write small functions with a single purpose
● Run them on on-demand compute services
● Compose them to build event-driven pipelines
● ...
14/51
S3 file upload
triggers
lambda_handler
15/51
lambda_handler
CloudWatch
schedule
triggers
16/51
lambda_handlerAPI Gateway
triggers
17/51
def request_handler(event, context):
...
return {
‘statusCode’: 200,
‘headers’: {...},
‘body’: ‘...’
}
18/51
SERVERLESS PRINCIPLES
● Write small functions with a single purpose
● Run them on on-demand compute services
● Compose them to build event-driven pipelines
● Use many external services
19/51
lambda_handlerS3 file upload
triggers
calls
saves
Elastic TransCoder
Firebase
20/51
API Gateway
triggers
RDS (MySQL)
uses
21/51
API Gateway
triggers
RDS (MySQL)
uses
22/51
23/51
lambda_handler
triggers
API Gateway
webhook
Firebase
updates
notifies
24/51
25/51
26/51
triggers
Firebase
API Gateway request handler DynamoDB
saves
triggers
request handler
triggers
request handler
RDS (MySQL)
saves saves
notifies
27/51
Real-life example #1: Airbnb’s Stream alert
https://github.com/airbnb/streamalert
28/51
Real-life example #2: acloud.guru
29/51
Real-life example #3: Droplr
30/51
Real-life example #3: Droplr
https://serverless.com/blog/how-droplr-scales-to-millions-serverless-framework/
lambda_handler
CloudWatch
schedule
triggers
lambda_handler
Simple Notification
Service
triggers
31/51
Real-life example #3: Droplr
https://serverless.com/blog/how-droplr-scales-to-millions-serverless-framework/
lambda_handlerAPI Gateway
triggerswebhooks
webhooks
32/51
SERVERLESS
Pros
Faster time to market
......
......
33/51
SERVERLESS
Pros
Faster time to market
Easy to learn...
......
34/51
SERVERLESS
Pros
Faster time to market
Easy to learnEasy to scale
......
35/51
SERVERLESS
Pros
Faster time to market
Easy to learnEasy to scale
Writing a small
function fits into
one iteration
(sprint)
...
36/51
SERVERLESS
Pros
Faster time to market
Easy to learnEasy to scale
Writing a small
function fits into
one iteration
(sprint)
Lower costs*
37/51
SERVERLESS
Cons
Vendor lock-in
...
...
......
38/51
SERVERLESS
Cons
Vendor lock-in
Communication
overhead
...
......
39/51
SERVERLESS
Cons
Vendor lock-in
Communication
overhead
Hard to test
......
40/51
SERVERLESS
Cons
Vendor lock-in
Communication
overhead
Hard to test
No bleeding
edge language
versions
...
41/51
SERVERLESS
Cons
Vendor lock-in
Communication
overhead
Hard to test
No bleeding
edge language
versions
Not always cost
efficient*
42/51
SERVERLESS PRICING (THE TRICKY PART)
43/51
SERVERLESS PRICING (THE TRICKY PART)
44/51
SERVERLESS
Good use cases
mostly static pages
(e-commerce)
......
45/51
SERVERLESS
Good use cases
mostly static pages
(e-commerce)
... IoT
46/51
SERVERLESS
Good use cases
mostly static pages
(e-commerce)
actions users
pay for
IoT
47/51
SERVERLESS
Bad use cases
Websockets
......
48/51
SERVERLESS
Bad use cases
Websockets
Unstable APIs
clients
...
49/51
SERVERLESS
Bad use cases
Websockets
in-memory
cache &
long-living state
Unstable APIs
clients
50/51
SERVERLESS
SUMMARY
51/51

Serverless