Upload
nodejsfoundation
View
106
Download
2
Embed Size (px)
Citation preview
The Hitchhiker’s Guide to “Serverless” Javascript
Steve Faulkner, Bustle
Steve Faulkner
@southpolesteve
Director of Platform
Engineering
hype! serverless 101
why? why not?
serverless @ bustle tools
The people who are serving websites on Lambda or something are not only doing it wrong, they are wasting money while locking themselves in to an architecture
that doesn't fit their app
- @scrollaway on HN
doesn’t scale not production ready
too slow too expensive
serverless for 99% of user requests
10-20 million calls per day
< 200ms
< $$$
Serverless 101
there are still servers…
…but what if we abstracted them away?
as a Service
Where does the business logic go?
Functions as a Service
run only when needed
pay only when running
don’t bother me with details
request myApp() response
re:invent happening right
now…
app.get(‘/‘, sayHello)
function sayHello(req,res){ res.end(‘hello!’) }
app.get(‘/‘, sayHello)
function sayHello(req,res){ res.end(‘hello!’) }
app.get(‘/‘, sayHello)
function sayHello(req,res){ res.end(‘hello!’) } Functions
Routing
Functions-aaS +
Routing-aaS
Lambda +
API Gateway
Lambda
write code zip
upload fn()
node java python
node shim +
rust/go/haskell
function(event,context,cb){ cb(null, ‘Hello World’) }
versioning aliases RAM + CPU logging
non-http events
API Gateway
click around a lot
cache/throttle authorization
api keys logging/metrics custom domains
ssl swagger import/export
why serverless?
ops
2011 startup ops: heroku down? get lunch!
2016 startup ops:have a plan
serverless ops: LOL! WAT SERVERS?
serverless ops: LOL! WAT SERVERS?
#noops
“serverless” ops: have a plan
benchmarksfallbacks
load testing monitoring#lessops
scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale scale
1 -> 1000 RPS
1000 -> 0 RPS
iteration
single function deployments
<1s deploys
$$$$
events API
ec2 ~$2500/mo
lambda api gateway ~$400/mo
why not?
lock in
const express = require(‘express’) const fn = require(./lambda-fn/) const app = express()
app.get('/', (req, res) => { fn.handler(null, null, (err, result) => { res.json(result) }) });
app.listen(3000)
cold functions
const data = loadBigData() // Takes 15s
module.exports.handler = function(e,ctx,cb){ processBigData(data, cb) }
~3.5 hours- Eric @ iopipe.com
long tasks
5 min max
s3(3GB) Lambda
Kinesis Firehose Elasticsearch
testing
test in the cloud?
frontend
API Gateway
S3 Lambda(SSR)
html + js
backend
API Gateway
Lambda
JSON
dynamodb redis
tools!!!
serverless framework node-lambda
apex claudia.js
npm install -g shep
JavaScript Only no CF,terraform
swaggerwebpack
environments
shep new my-api shep generate endpoint shep deploy production
coming soon…
shep server shep docs
shep logs —stream
questions?
Steve Faulkner @southpolesteve