@simalexan
STARTUP
INNOVATIVE HIPSTER UNICORN with VCs
+
AGILE and SCRUM…
+
millions $$$
+
200,000s users
Slide 7
Slide 7 text
@simalexan
BUILDING APPS
Customers
(Angular)
API
Admin
(Angular)
Company site
(Wordpress)
Elastic
Search
Other
services
Owners
(Angular)
PG
As engineers, this what we really want to do.
Slide 8
Slide 8 text
@simalexan
SERVING CUSTOMERS
What did we use (server-hosted)
• Heroku
• EC2
• Azure
Development Staging Production
Environments (per server)
Building apps is the core, but we have to do run them too.
Slide 9
Slide 9 text
@simalexan
ORGANIZE SERVING
CUSTOMERS
Customers
(Angular)
API
Admin
(Angular)
Company site
(Wordpress)
Elastic
Search
Other
services
Owners
(Angular)
PG
x 3
Server Server Server
Big A** Server
@simalexan
WHAT HAPPENED?
• Marketing set an unannounced advertising.
100,000 new users in 1h > crashed immediately
- “Next time, we’ll be better.”
• 2 months later
DDoS attack > 48 service NA
• 1 month later.
Elastic search overflowed > API crashed > Web apps stuck
• Three months later?
- “Next time, we’ll be better.”
Slide 14
Slide 14 text
@simalexan
“Why not just
get bigger servers
and
estimate better?”
MANAGEMENT:
Slide 15
Slide 15 text
@simalexan
Slide 16
Slide 16 text
@simalexan
BIGGER SERVERS
Slide 17
Slide 17 text
@simalexan
TOTAL COST
~ $3000
per month
Slide 18
Slide 18 text
@simalexan
MORE CUSTOMERS
COMPLEXITY
MORE SERVERS
PROBLEMS
Why?
Slide 19
Slide 19 text
@simalexan
Average API server usage
Usage
Intervals
35%
60%
80%
06 09 12 15 18
70%
45%
21 00 03 06
0%
100%
This is normal. Good?
Price: 100$
Slide 20
Slide 20 text
@simalexan
What if we change
perspective?
Slide 21
Slide 21 text
@simalexan
Average API server WASTED TIME
Intervals
65%
40%
20%
99%
30%
55%
95% 99%
0%
100%
Bad enough?
Waste
06 09 12 15 18 21 00 03 06
Slide 22
Slide 22 text
@simalexan
~ 62.8%
wasted resources
~ $1900
Slide 23
Slide 23 text
@simalexan
UNEXPECTED PEAK?
Usage
Intervals
35%
60%
110%
70%
45%
0%
100%
New customers
are a problem ?!
“Unexpected”
peak
new
capacity
06 09 12 15 18 21 00 03 06
=
Slide 24
Slide 24 text
@simalexan
Yes, we can burn more!
Because, why not?
Slide 25
Slide 25 text
@simalexan
new API server usage
Usage
Intervals
28%
54%
80%
63%
38%
0%
100%
We are “safe” now!
Buffer
New Price: 150$ - (if you’re lucky)
06 09 12 15 18 21 00 03 06
Slide 26
Slide 26 text
@simalexan
Need more servers?
Slide 27
Slide 27 text
@simalexan
Just do it!
We have a million dollar investment!
Slide 28
Slide 28 text
@simalexan
USUAL ISSUES
• Most of the time waiting for a request
• Maximum capacity
• One service can eat up the memory and kill others
• Recovery time (2-7h)
• Sometimes you have to call your DevOps
• It’s stupid to run just one small application
• Renting a new server and setup takes > 1h
Slide 29
Slide 29 text
Similar to?
Slide 30
Slide 30 text
Washing machines? Really?
Slide 31
Slide 31 text
@simalexan
< 5kg
Processing machine
Different clothes
Max weight
Can be bigger > handles more
Can be smaller > more efficient
Slide 32
Slide 32 text
@simalexan
USUAL ISSUES
• Mostly waiting for clothes
• Maximum capacity
• One cloth color can spoil the other - my special princess dress
• Recovery time (2h - 1 day)
• Sometimes you have to call the plumber
• Buying a new washing machine and setting it up >2h
• Its stupid to wash just one shirt
Slide 33
Slide 33 text
@simalexan
Slide 34
Slide 34 text
@simalexan
Feels familiar?
Slide 35
Slide 35 text
@simalexan
• Mostly waiting for requests
• Max capacity
• One service can eat up the memory
and kill others
• Recovery time (2-7h)
• Sometimes you have to call the
DevOps
• It’s stupid to run one small service
• Renting a new server and setup
takes > 1h
• Mostly waiting for clothes
• Max capacity
• One cloth color can spoil the other
• Recovery time (2h - 1 day)
• Sometimes you have to call the
Plumber
• It’s stupid to wash one shirt
• Buying a new washing machine
and setup > 1h
Can’t be the same?
Slide 36
Slide 36 text
@simalexan
How did the laundry
industry evolve?
1934.
First
“Laundromat”
1950s
Mass
Laundromats
1970s 2000s
First
“Fluff and Fold”
Mass
“Fluff and Fold”
=
decline of
laundromats
Slide 37
Slide 37 text
@simalexan
Fluff and Fold
• Cleaning service with pickup and
delivery
• Pay per item
• Can clean 1 or 1000 clothes
Disclaimer: The name didn’t originate from 4chan.
Slide 38
Slide 38 text
@simalexan
you don’t care about
washing machines and
their detergent setup
Fluff and Fold
means
Slide 39
Slide 39 text
@simalexan
you don’t care about
max capacity and
plumbers
Fluff and Fold
also means
Slide 40
Slide 40 text
@simalexan
How did our industry
evolve?
2001.
First
“VPS”
2005
Mass
VPS
The “Cloud”
?
?
Slide 41
Slide 41 text
@simalexan
Is serverless
our “Fluff and Fold”?
Slide 42
Slide 42 text
@simalexan
Or is serverless just a bad
advertising..?
Slide 43
Slide 43 text
@simalexan
Like this?
Slide 44
Slide 44 text
@simalexan
SERVERLESS
•Method of running and deploying software
without renting or buying a server
•Pay per request execution
•Can scale services from 1 to 1000
Slide 45
Slide 45 text
@simalexan
you don’t care about
servers and
server configuration
Serverless
means
Slide 46
Slide 46 text
@simalexan
you don’t care about
scaling and
balancing
Serverless
also means
Slide 47
Slide 47 text
@simalexan
you don’t care about
max capacity and
DevOps
Serverless
also means
Slide 48
Slide 48 text
@simalexan
Serverless does not exclude the existence of servers.
SERVERLESS
But it does however, have a name.
Slide 49
Slide 49 text
@simalexan
HOW DOES IT WORK?
A micro isolated environment with
everything your code needs
a plant pot
Treats your code as a function
Function containers
Slide 50
Slide 50 text
@simalexan
AUTOSTART
No request?
function ()
function ()
Request
Cold start: up to few seconds
Slide 51
Slide 51 text
@simalexan
HOW DOES THAT HELP?
Slide 52
Slide 52 text
@simalexan
EVENT DRIVEN
FUNCTION SCALING
function ()
function ()
Request!
Request!
Request!
Request!
Request!
Request!
Request!
Slide 53
Slide 53 text
@simalexan
EMPHASIZES
RESTRUCTURING and
MICRO SERVICES
Slide 54
Slide 54 text
@simalexan
Server hosted API structure
Login
Generate
PDF
Products
Orders
Send
Emails
Payment
Users
Shopping
Cart
Chatbot
Reports
Process
pictures
Register
API
File storage
Database
API endpoints
Slide 55
Slide 55 text
@simalexan
Scaling a server hosted API
File storage
Database
Logi Gen Pro
Ord
Sen
Pay
Use
Sho Cha
Rep
Proc
Regi
API endpoints
Logi Gen Pro
Ord
Sen
Pay
Use
Sho Cha
Rep
Proc
Regi
API endpoints
Logi Gen Pro
Ord
Sen
Pay
Use
Sho Cha
Rep
Proc
Regi
API endpoints
Logi Gen Pro
Ord
Sen
Pay
Use
Sho Cha
Rep
Proc
Regi
API endpoints
Slide 56
Slide 56 text
@simalexan
Serverless API structure
Generate
PDF
File storage
Database
API Gateway
Login
Register
Orders Users
Chatbot
Process
pictures
Shopping
Cart
Products
Payment
Reports
Send
Emails
Slide 57
Slide 57 text
@simalexan
Orders
Scaling a serverless API
API Gateway
Login
Register
Orders
Users
Chatbot
Shopping
Cart
Products
Payment
Send
Emails
Products Products Products Products
Orders
Some are more used
than others!
Some are not used at
all!
Slide 58
Slide 58 text
@simalexan
You don’t pay
if no one
is using it
Serverless
also means
Slide 59
Slide 59 text
@simalexan
PROVIDERS
(most notable)
AWS Lambda
Azure Function
Google Cloud Function
IBM OpenWhisk
Slide 60
Slide 60 text
@simalexan
PRICING
AWS Lambda
$0.0000002
PER REQUEST
$0.000000834
PER REQUEST
100ms @ 512MB
1,000,000
REQUESTS PER MONTH
FREE
NEXT
~ $0.20
TOTAL
VARIOUS SIZES
PER MILLION
Slide 61
Slide 61 text
@simalexan
PRICING
$0.000016
GB-s
$0.000000586
PER REQUEST
100ms @ 512MB
1,000,000
EXECUTIONS PER MONTH
FREE
NEXT
~ $0.20
TOTAL
VARIOUS SIZES
PER MILLION
Azure Function
Slide 62
Slide 62 text
@simalexan
PROGRAMMING
LANGUAGES?
Slide 63
Slide 63 text
@simalexan
AWS Lambda
SHELL SCRIPTS
ANY EXECUTABLE
Slide 64
Slide 64 text
@simalexan
SHELL SCRIPTS
ANY EXECUTABLE
Azure Function
Slide 65
Slide 65 text
@simalexan
How does it work with
AWS Lambda Example
@simalexan
Characteristics
• Deploy with a single command
• Get started quickly, flat learning curve
• No boilerplate
• Use standard NPM modules
• Multiple versions very easily
Slide 72
Slide 72 text
@simalexan
’use strict’
const Api = require(’claudia-api-builder’)
const api = new Api()
api.get(‘/’, () =>”Hello Kharkiv!”)
module.exports = api
index.js
Slide 73
Slide 73 text
@simalexan
claudia create \
—-region eu-central-1 \
—-api-module index
claudia update
in your console/terminal
@simalexan
improved stability and
autofailover
Serverless
has
function ()
Orders Chatbot
Send
Emails
Products
Slide 81
Slide 81 text
@simalexan
focuses on business logic,
not configuration
Serverless
Slide 82
Slide 82 text
@simalexan
minimal maintenance
Serverless
has
Slide 83
Slide 83 text
@simalexan
costs less
Serverless
USED TIME
RESERVED
Slide 84
Slide 84 text
@simalexan
Servers have become a
commodity
Just as water evolved to be pay-per-use
Slide 85
Slide 85 text
@simalexan
Isn’t good for?
Serverless
Slide 86
Slide 86 text
@simalexan
- Real time applications with Sockets
- Extremely low latency apps < 100ms
- Long running tasks
- Very specific configurations
- Need an SLA
NOT GOOD FOR
Slide 87
Slide 87 text
@simalexan
Is good for?
Serverless
Slide 88
Slide 88 text
@simalexan
GOOD FOR
• Web APIs
• Micro services
• Chatbots
• IoT
• File/Image processing
• Rapid prototyping, very quick “time to deploy”
Slide 89
Slide 89 text
@simalexan
“Hidden” Benefits?
Slide 90
Slide 90 text
@simalexan
REFACTORING
• Makes sense as it has a financial incentive
• Better code, less cost
• No more: “Well, its working OK…”
Slide 91
Slide 91 text
@simalexan
CODE EFFICIENCY
• Slower code has bigger repercussions.
• Algorithms having a stronger impact
(start reading)
Slide 92
Slide 92 text
@simalexan
PRODUCTION
• CodePen - Claudia.js for preprocessors
• MindMup
• Autodesk - Forgeviewer
• Shippo
Slide 93
Slide 93 text
@simalexan
SUMMARY
• Serverless means no server configuration
• Autoscaling and autofailover
• Function deployment
• Effortless with Claudia.js
• Event driven
• Rapid deployment
• Works great with Node.js
Slide 94
Slide 94 text
@simalexan
Look Mama, a server rack!
Slide 95
Slide 95 text
@simalexan
SERVERLESS CAMP
Slide 96
Slide 96 text
@simalexan
effortless-serverless.com
claudiajs.com
Serverless Apps with Node and Claudia.js
Just during KharkivJS
Get the book 40% off with ctwkharkivjs