Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~...

26
Introduction to Serverless PHP Rob Allen June 2018

Transcript of Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~...

Page 1: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

Introduction toServerless PHP

Rob Allen  

June 2018

Page 2: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

Deployment options1. Physical servers2. Virtual machines3. Containers

Rob Allen ~  @akrabat

Page 3: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

Container deployments1. Platform (e.g. Kubernetes)2. Application (e.g. Cloud Foundry)3. Serverless (e.g. OpenWhisk)

Rob Allen ~  @akrabat

Page 4: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

Serverless? 

The first thing to know about serverlesscomputing is that "serverless" is a pretty badname to call it.

- Brandon Butler, Network World

Rob Allen ~  @akrabat

Page 5: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

AKA: Functions as a Service• A runtime to execute your functions• No capacity planning or load balancing; just tasks being

executed.• Pay for execution, not when idle

Rob Allen ~  @akrabat

Page 6: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

Use-casesSynchronousService is invoked and provides immediate response(HTTP requests: APIs, chat bots)

AsynchronousPush a message which drives an action later(web hooks, timed events, database changes)

StreamingContinuous data flow to be processed

Rob Allen ~  @akrabat

Page 7: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

Benefits• No need to think about servers• Concentrate on application code• Pay only for what you use, when you use it• Language agnostic: NodeJS, Swift, Python, Java, C#, etc

Rob Allen ~  @akrabat

Page 8: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

Challenges• Start up latency• Time limit• State is external• DevOps is still a thing

Rob Allen ~  @akrabat

Page 9: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

It's about value

Rob Allen ~  @akrabat

Page 10: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

When should you use serverless?• Occasional server needs on a static site• Variable traffic levels• Additional compute without extending current platform• Responding to web hooks

Rob Allen ~  @akrabat

Page 11: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

Serverless providers

Rob Allen ~  @akrabat

Page 12: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

OpenWhisk

Rob Allen ~  @akrabat

Page 13: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

OpenWhiskOpenSource; multiple providers:

IBMRedHatAdobe (for Adobe Cloud Platform APIs)

&, of course, self-hosted

Rob Allen ~  @akrabat

Page 14: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

Invoking an action

Rob Allen ~  @akrabat

Page 15: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

Serverless PHP

Rob Allen ~  @akrabat

Page 16: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

Hello world in PHP

Rob Allen ~  @akrabat

Page 17: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

Hello world in PHP

Rob Allen ~  @akrabat

Page 18: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

Running your action$ wsk action update hello hello.phpok: updated action hello

$ wsk action invoke hello --result{ "msg": "Hello World"}

Rob Allen ~  @akrabat

Page 19: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

DependenciesZip them up$ zip -r hello.zip hello.php vendor$ wsk action update hello hello.zip --kind php:7.1

Rob Allen ~  @akrabat

Page 20: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

Web accessAdd the --web flag:$ wsk action update hello hello.php --web true$ curl https://openwhisk.ng.bluemix.net/api/v1/web/ \ 19FT_demo/default/hello.json

Rob Allen ~  @akrabat

Page 21: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

What to do in your action• Compute!• Store to database• Make API calls to other services• Store to cloud storage (S3)• Trigger other actions

Rob Allen ~  @akrabat

Page 22: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

Demo time!

Rob Allen ~  @akrabat

Page 23: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

To sum up

Rob Allen ~  @akrabat

Page 24: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

Resources• http://www.openwhisk.org• https://medium.com/openwhisk• https://github.com/akrabat/ow-php-ftime• https://www.martinfowler.com/articles/serverless.html

Rob Allen ~  @akrabat

Page 25: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

Questions?

Rob Allen ~  @akrabat

Page 26: Introduction to Serverless PHP - on.notist.cloud · Serverless (e.g. OpenWhisk) Rob Allen ~ @akrabat. Serverless? The first thing to know about serverless computing is that "serverless"

Thank you!

Rob Allen ~  @akrabat