The Serverless Revolution for JavaScript Developers Pam Selle, - - PowerPoint PPT Presentation

the serverless revolution for javascript developers
SMART_READER_LITE
LIVE PREVIEW

The Serverless Revolution for JavaScript Developers Pam Selle, - - PowerPoint PPT Presentation

The Serverless Revolution for JavaScript Developers Pam Selle, IOpipe @pamasaur | thewebivore.com The Serverless Revolution for JavaScript Developers Pam Selle, IOpipe @pamasaur | thewebivore.com 5 million requests for $5 (really $4.55)


slide-1
SLIDE 1

The Serverless Revolution for JavaScript Developers

Pam Selle, IOpipe @pamasaur | thewebivore.com

slide-2
SLIDE 2

The Serverless Revolution for JavaScript Developers

Pam Selle, IOpipe @pamasaur | thewebivore.com

slide-3
SLIDE 3

5 million requests for $5

(really $4.55)

http://serverlesscalc.com/

slide-4
SLIDE 4

Q: Over how long? A: Doesn’t matter

slide-5
SLIDE 5

“NoOps”

slide-6
SLIDE 6

“No server is easier to manage than ‘no server’”

  • Matt Wood, GM Product Strategy, AWS

Source: http://www.businessinsider.com/amazon-web-services-lambda-explained-2015-11

slide-7
SLIDE 7

Serverless architectures allow you to focus on deploying code that Does Things

slide-8
SLIDE 8

Rather than focusing

  • n server management

;)

slide-9
SLIDE 9

What is serverless really?

slide-10
SLIDE 10

FaaS & BaaS

slide-11
SLIDE 11

FaaS: Functions as a Service

aka: “serverless computing”

slide-12
SLIDE 12

FaaS: Running code

  • n-demand in

response to a defined trigger

slide-13
SLIDE 13

FaaS Providers

Left to right: Google Cloud Platform, AWS Lambda, Azure Functions, Webtask, Iron.io, IBM OpenWhisk

slide-14
SLIDE 14

BaaS: Backend as a Service

aka: “going serverless”

slide-15
SLIDE 15

BaaS: Relying on other services for your backend needs

slide-16
SLIDE 16

BaaS offerings

Lots more: https://github.com/anaibol/awesome-serverless

slide-17
SLIDE 17

The rise of FaaS

slide-18
SLIDE 18

Servers in Datacenter Functions as a Service (FaaS)

How we got to now

Servers in Cloud

slide-19
SLIDE 19

How your code runs on FaaS

{ event }

Up to 1000 concurrent (can be raised)

slide-20
SLIDE 20

Why does FaaS work now?

  • Container technology enabled FaaS
  • Friendly to providers for efficient use of infrastructure
  • Metering model cost-friendly to customers
  • NoOps/“no server” reduces operations costs
slide-21
SLIDE 21

2014 Release

AWS Lambda is a compute service that runs your code in response to

events and automatically manages the compute resources for you […] With Amazon

Lambda, you pay only for the requests served and the compute time required to run your

  • code. Billing is metered in increments of 100 milliseconds,

making it cost-effective and easy to scale automatically from a few requests per day to thousands per second.

(Source: https://aws.amazon.com/releasenotes/AWS-Lambda/8269001345899110, emphasis added)

slide-22
SLIDE 22

FaaS Pricing

Cost = Invocations + Compute time

slide-23
SLIDE 23

What’s a GB-second?

  • GB-seconds are a measure of compute time
  • 1 second with 1GB of memory provisioned = 1 GB-s
  • If you provision your funcs to use more memory, you use more GB-s each

running second (billed in 100 ms)

Memory (MB) % GB-s Cost for 100ms (Lambda price) 128 12.5% $0.000000208 1024 100% $0.000001667

slide-24
SLIDE 24
  • Original, released in 2014
  • Integrates seamlessly with many AWS services:

API Gateway, Kinesis, DynamoDB, SNS, many more

  • Languages: NodeJS, Python, Java, C#

AWS Lambda

Free tier invocations 1 million Free tier compute time 400k GB-s Invocations $0.20/million ($0.0000002 each) Compute time $0.00001667/GB-second

slide-25
SLIDE 25

Google Cloud Functions

  • HTTP triggers, Pub/Sub, Storage
  • Local emulator (alpha)
  • Languages: NodeJS

Free tier invocations 2 million Free tier compute-time 400k GB-s Invocations $0.40/million ($0.0000004 each) Compute time $0.00001667/GB-second Outgoing network requests $0.12/GB (5GB free)

slide-26
SLIDE 26

Azure Functions

  • HTTP/webhooks (incl. Defaults for Slack, GitHub),

Schedules, Storage, Azure Event Hub, Queues

  • Languages: NodeJS, C# (but also F#, Python, PHP,

Bash, Batch, and PowerShell)

Free grant invocations 1 million Free grant compute-time 400k GB-s Invocations $0.20/million ($0.0000002 each) Compute time $0.00001667/GB-second

slide-27
SLIDE 27

Don’t want to run on a public cloud?

  • Apache OpenWhisk
  • Run your own NoOps infrastructure
  • https://github.com/openwhisk/openwhisk
slide-28
SLIDE 28

Which one should I use?

  • AWS is mature, focus of much tooling
  • GCF has a larger free tier

¯\_(ツ)_/¯ try them out!

slide-29
SLIDE 29

Deploying a serverless function

slide-30
SLIDE 30

Deploying functions

1. Upload the code (default limit 50mb for Lambda)

slide-31
SLIDE 31

Deploying functions

1. Upload the code (that’s it)

slide-32
SLIDE 32

Aside: If what runs is what you upload, what does that mean about binaries?

slide-33
SLIDE 33

Deploying functions (more realistic)

  • Use tooling for CLI and CI/CD
  • Provision and delegate resources
  • Clean up resources as necessary
slide-34
SLIDE 34

Deployment options

  • Serverless Framework
  • Apex
  • Zappa (Python)
  • Chalice (Python, AWS)
  • ClaudiaJS (Node)
  • Shep
  • (there are more!)
slide-35
SLIDE 35

Basic code for a FaaS

console.log('this prints on a coldstart') exports.hello = function(event, context, callback) { console.log('processing event: %j', event) // callback(error, success) callback(null, { hello: 'world' }) // context.fail() // context.succeed() };

slide-36
SLIDE 36

Basic code for a FaaS

console.log('this prints on a coldstart') exports.hello = function(event, context, callback) { console.log('processing event: %j', event) // callback(error, success) callback(null, { hello: 'world' }) // context.fail() // context.succeed() };

slide-37
SLIDE 37

Basic code for a FaaS

console.log('this prints on a coldstart') exports.hello = function(event, context, callback) { console.log('processing event: %j', event) // callback(error, success) callback(null, { hello: 'world' }) // context.fail() // context.succeed() };

slide-38
SLIDE 38

Basic code for a FaaS

console.log('this prints on a coldstart') exports.hello = function(event, context, callback) { console.log('processing event: %j', event) // callback(error, success) callback(null, { hello: 'world' }) // context.fail() // context.succeed() };

slide-39
SLIDE 39

Basic code for a FaaS

console.log('this prints on a coldstart') exports.hello = function(event, context, callback) { console.log('processing event: %j', event) // callback(error, success) callback(null, { hello: 'world' }) // context.fail() // context.succeed() };

slide-40
SLIDE 40

Basic deployment code for a FaaS using Serverless Framework

service: ourService provider: name: aws runtime: nodejs6.10 functions:

  • urFunction:

handler: handler.hello # assuming file is called “handler” memorySize: 128 events:

  • http:

path: hello method: get

slide-41
SLIDE 41

$ sls create --template aws-nodejs

slide-42
SLIDE 42

Demo: OSCON Photo Booth!

slide-43
SLIDE 43

https://youtu.be/YjHxAlllFLo

slide-44
SLIDE 44

Make your own photo booth selfie: pselle.github.io/oscon-photo-booth

Disclaimer! It’s slow!

slide-45
SLIDE 45

Check out the code: github.com/pselle/oscon-photo-booth

slide-46
SLIDE 46

Ways to use serverless computing

  • Serving APIs
  • Mobile apps
  • IoT
  • Data analysis
  • Operations tasks (ex. cleanup)
slide-47
SLIDE 47

… or a serverless longboard :)

https://twitter.com/nodebotanist/status/851571 198983122945

slide-48
SLIDE 48

FaaS in production

slide-49
SLIDE 49

Bustle

  • Converted from a monolith architecture

that was difficult to scale

  • ~12 APIs in production
  • 100 million events per day
  • Leveraging: GraphQL, Kinesis, API

Gateway

“The size of our team is half of what is normally needed to build and

  • perate a site of this scale.”
  • Tyler Love, CTO

Women’s interest website with 50MM+ readers/month

https://aws.amazon.com/solutions/case-studies/bustle/ https://thenewstack.io/bustle-migrated-100-million-event s-per-day-product-serverless/

slide-50
SLIDE 50

Hundreds of brands, vending powered by serverless

Major productivity gains from going serverless!

  • Went from 24% unplanned

work to 6%

  • 68% of time spent on biz

projects (vs 39%)

re:Invent https://www.youtube.com/watch?v=yErmil00DYs

Coca-Cola

slide-51
SLIDE 51

Captures and analyzes every play

“Lambda is really clever. It’s where we take the raw data, do some cleaning up and error detection, then create the metrics that bring more insights into plays—the throws, the player’s acceleration rate, the top running speeds … We’re accessing a truly big data mine, and have yet to scratch the surface." https://aws.amazon.com/solutions/case-studies/major

  • league-baseball-mlbam/

MLB Advanced Media

slide-52
SLIDE 52

What should you check out next?

  • Deploy a serverless function (or lots of them)
  • Explore event sources – the options are endless
  • Look into GraphQL
  • The awesome-serverless list
  • More further reading: https://martinfowler.com/articles/serverless.html
slide-53
SLIDE 53

Challenges of Serverless (what’s next)

  • State
  • Orchestration
  • Deployment
  • Testing
  • Debugging
  • Networking
  • Monitoring
slide-54
SLIDE 54

Thank you!

@pamasaur @iopipes www.iopipe.com