Top Banner
Removing Application Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle [email protected] Alpha Particle @kkoppenhaver
36

Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle [email protected] Alpha Particle ... Python [beta] and

May 24, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Removing Application Bottlenecks with Serverless

Keanan Koppenhaver CTO, Alpha Particle

[email protected]

Alpha Particle

@kkoppenhaver

Page 2: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

@kkoppenhaver

[email protected]

https://joind.in/talk/a6cc7

Page 3: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Talk as a post (TaaP)* https://www.awsadvent.com/2018/12/05/scaling-up-an-

existing-application-with-lambda-functions/

[email protected]

Alpha Particle

@kkoppenhaver

Page 4: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Serverless is a bit of a misnomer

[email protected]

Alpha Particle

@kkoppenhaver

Page 5: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

[email protected]

Alpha Particle

@kkoppenhaver

Page 6: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

[email protected]

Alpha Particle

@kkoppenhaver

Page 7: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

[email protected]

Alpha Particle

@kkoppenhaver

The 30,000 ft viewYou don’t have to worry about the server

You don’t have to worry about scaling

You only pay for the time the code is running (100ms increments)

Most providers have a generous free plan

Page 8: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

[email protected]

Alpha Particle

@kkoppenhaver

The 30,000 ft view (cont’d)AWS LAmbda

- Java, Go, PowerShell, Node.js, C#, Python, and Ruby (but now also anything*)

Google Cloud functions - Node.js, Python [beta] and Go [beta]

Azure Functions - C#, Node.js, F#, Java, Python [Experimental]

Page 9: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

What makes a good candidate For serverless?

[email protected]

Alpha Particle

@kkoppenhaver

Function as a service (Faas)

Can run without much reliance on state

Trigger -> Action -> Result

Invoker doesn’t care about the result

Page 10: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Serverless Triggers

[email protected]

Alpha Particle

@kkoppenhaver

API Endpoint

Filesystem changes (S3, etc…)

Alexa/Google Home (api endpoint in disguise)

Most of a cloud provider’s other services….

Page 11: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Common serverless use cases

[email protected]

Alpha Particle

@kkoppenhaver

Image processing (Filesystem trigger)

Log processing

CI/CD Tasks

IoT

Voice Skills, Chat bots, etc…

Page 12: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Part 1 | What’s the problem?

[email protected]

Alpha Particle

@kkoppenhaver

Page 13: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

SNapsure

[email protected]

Alpha Particle

@kkoppenhaver

Page 14: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and
Page 15: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Snapsure

[email protected]

Alpha Particle

@kkoppenhaver

Each potential alert contains (Potentially) more than a few api calls

Alerts can start to stack up and eat up server resources

Scale horizontally or…serverless?

Page 16: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Snapsure (cont’d)

[email protected]

Alpha Particle

@kkoppenhaver

API Trigger

Alert params are passed as JSON

Params are evaluated against different Apis to determine whether alert needs to be sent

Infinite scale and Concurrency*

Page 17: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Part 2 | Slackbot

[email protected]

Alpha Particle

@kkoppenhaver

Page 18: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Slackbot

[email protected]

Alpha Particle

@kkoppenhaver

constant Requests for membership data (log in, phpmyadmin, Mysql query)

Set up api endpoint in laravel to expose some DB values

Create a stats slackbot that can hit this api endpoint

SErverless sits in the middle to add ability to expand in the future

Page 19: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and
Page 20: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

DEMO

[email protected]

Alpha Particle

@kkoppenhaver

Page 21: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Part 3 | Development workflow

[email protected]

Alpha Particle

@kkoppenhaver

Page 22: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and
Page 23: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and
Page 24: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

In-browser development

[email protected]

Alpha Particle

@kkoppenhaver

Super easy to get up and running, but…

Size limitations

Hard to bundle dependencies

Really not a great ide

Page 25: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Actual local development

[email protected]

Alpha Particle

@kkoppenhaver

Page 26: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

[email protected]

Alpha Particle

@kkoppenhaver

Actual local developmentAWS LAmbda

- SAM LOCAL CLI (Docker-based environment for local development)

Google Cloud functions - Node.js local emulator

Azure Functions - Very tight integration with VS code, entire environment exists there

Page 27: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Actual local development

[email protected]

Alpha Particle

@kkoppenhaver

Super easy to get up and running, but…

Size limitations

Hard to bundle dependencies

Really not a great ide

Page 28: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Some other “issues”

[email protected]

Alpha Particle

@kkoppenhaver

Page 29: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Deployment

[email protected]

Alpha Particle

@kkoppenhaver

In browser == no problem

For local development == zip file with all dependencies

Deployed using the cli for cloud provider of your choice

Can be hooked into VCS and CI/CD as well

Page 30: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Monitoring

[email protected]

Alpha Particle

@kkoppenhaver

Cloud provider of choice probably has a monitoring tool

Debugging errors in the browser is hard (so test locally)

Set up any custom metrics you want to track

Page 31: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Part 4 | What’s coming next?

[email protected]

Alpha Particle

@kkoppenhaver

Page 32: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Php (!!)

https://aws.amazon.com/blogs/apn/aws-lambda-custom-runtime-for-php-a-practical-example/

[email protected]

Alpha Particle

@kkoppenhaver

Page 33: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Runtime api

[email protected]

Alpha Particle

@kkoppenhaver

Can run any language the underlying linux environment can run

Usually Packaged in a layer (see next slide)

Bootstrap script - Give php access to anything it needs and set up event loop

getNextrequest() and sendResponse()

Lambda can now run php!

Page 34: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Layers

[email protected]

Alpha Particle

@kkoppenhaver

ZIP archive that contains libraries, custom runtime or other dependencies

(They don’t have to go in your deployment package anymore!)

A few more use-cases are now able to use the in-browser editor

Page 35: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

SErverless will continue to evolve

[email protected]

Alpha Particle

@kkoppenhaver

If you don’t need control over serveRs, it can provide simplicity

Some deployment/workflow concerns but tooling is getting better

Very inexpensive for most use cases

Fire and forget

Page 36: Removing Application Bottlenecks with Serverless · Bottlenecks with Serverless Keanan Koppenhaver CTO, Alpha Particle keanan@alphaparticle.com Alpha Particle ... Python [beta] and

Questions?@kkoppenhaver

[email protected]

https://joind.in/talk/a6cc7