Build serverless APIs

using Postman and Apache OpenWhisk

Joyce Lin

Developer Evangelist, Postman

 

Upkar Lidder

Developer Advocate, IBM

http://bit.ly/postman-ibm

https://www.getpostman.com

@lidderupk
IBM Developer

What is Serverless

Serverless computing refers to the concept of building and running applications that do not require server management.

 

It describes a finer-grained deployment model where applications, bundled as one or more functions, are uploaded to a platform and then executed, scaled, and billed in response to the exact demand needed at the moment.

 

It refers to the idea that consumers of serverless computing no longer need to spend time and resources on server provisioning, maintenance, updates, scaling, and capacity planning. Instead, all of these tasks and capabilities are handled by a serverless platform and are completely abstracted away from the developers​.

Cloud Native Computing Foundation

https://github.com/cncf/wg-serverless/tree/master/whitepapers/serverless-overview

@lidderupk
IBM Developer

Use Cases

  • Secure and scalable APIs
    • API Gateway Function
    • HTTP level scaling

 

  • Backend services / micro services
    • function/service level scaling
    • polyglot functions

 

  • Event Driven Programming
    • Changes in database
    • Social events
@lidderupk
IBM Developer

Leans well to ...

  • Small, focused, asynchronous, concurrent, easy to parallelize into independent units of work

 

  • Infrequent or has sporadic demand, with large, unpredictable variance in scaling requirements

 

  • Stateless, ephemeral, without a major need for instantaneous cold start time

 

  • Highly dynamic in terms of changing business requirements that drive a need for accelerated developer velocity

 

@lidderupk
IBM Developer

Example - Game App

@lidderupk
IBM Developer

Example - Conference App

@lidderupk
IBM Developer

Serverless Landscape

Hosted

Installable

https://github.com/cncf/landscape#serverless

@lidderupk
IBM Developer

Serverless Landscape

Amazon Lambda

•Node.js, Python, Java, C# and Go

 

IBM Cloud Functions

•Node.js 8, Node.js 6, Python 3.6.4, Python 3.6.1, PHP 7.1, PHP 7.2,  and Swift 4, Swift 3.1.1, Ruby 2.5, Docker

•Recent change – 2GB max memory and 10 minutes run limit.

 

Microsoft Azure

•C#, F#, Node.js (in GA), Java, Python, PHP, TypeScript, Bash, PowerShell (experimental mode)

 

Google Cloud Function

•Node.js, Python

This space is constantly changing !

@lidderupk
IBM Developer

Apache OpenWhisk

Apache OpenWhisk is an open source, distributed Serverless platform that supports a programming model in which developers write functional logic (called Actions), in any supported programming language, that can be dynamically scheduled and run (with Rules) in response to associated events (via Triggers) from external sources ( Feeds) or from HTTP requests.

@lidderupk
IBM Developer

Apache OpenWhisk

Packages
@lidderupk
IBM Developer

Apache OpenWhisk (js)

Entry point

Object In

Object Out

@lidderupk
IBM Developer

Apache OpenWhisk (js)

@lidderupk
IBM Developer

WSK CLI

@lidderupk
IBM Developer

WSK SYSTEM PACKAGES

@lidderupk
IBM Developer

WSK SYSTEM PACKAGES

@lidderupk
IBM Developer
@lidderupk

So much more ...

  • More Compositions - Use higher-level programming constructs to declaratively chain together multiple actions.
    • while, repeat, let, retry, try, if, etc

 

  • HTTP Actions (web == true)

 

  • Packages community (couchdb, kafka, etc)

 

  • API Gateway (rate limiting, authentication/authorization)

 

  • Install external packages, debugging, etc
@lidderupk
IBM Developer

Community and Help

  • Slack
  • http://openwhisk-team.slack.com/

 

 

  • Github and OpenWhisk docs

 

 

 

  • Youtube/Medium/Twitter

 

 

  • Bi-weekly interexchange meetings
@lidderupk
IBM Developer

Some things to 🤔

  • Functions are stateless. Need some sort of persistence between runs.
  • Are you able to test and develop locally ? Does provider have CLI ?
  • Can you easily version your functions ? Source control ?
  • Can you easily monitor your functions ?
  • Security and API gateway
  • Avoid long-running loops / mini-monoliths ?
  • Latency (cold, warm and hot loads)
  • How do you track dependencies ?
@lidderupk
IBM Developer

Thank you

 

Let's chat !

@lidderupk
IBM Developer

Upkar Lidder, IBM

 

@lidderupk

https://github.com/lidderupk/

ulidder@us.ibm.com

Solid Foundations

Leverages existing opensource solutions

@lidderupk
IBM Developer

Solid Foundations

Leverages existing opensource solutions

@lidderupk
IBM Developer

Built on Open Source

@lidderupk
IBM Developer

Apache OpenWhisk (create)

wsk action create helloJava target/hello-world-java.jar --main com.example.FunctionApp

@lidderupk
IBM Developer

Apache OpenWhisk (invoke)

wsk action invoke --result helloJava --param name World

@lidderupk
IBM Developer

Apache OpenWhisk - more real example

1user registers
2tail logs
3SMS
4email
@lidderupk
IBM Developer

Apache OpenWhisk - more real example

https://github.com/lidderupk/openwhisk-registration/tree/master/javascript

@lidderupk
IBM Developer

Composition / Orchestration

CONDITION Action Name

Code

THEN Action Name

Code

ELSE Action Name

Code

@lidderupk
IBM Developer

Composition / Orchestration

@lidderupk
IBM Developer

KUI Shell

@lidderupk
IBM Developer

KUI Shell

@lidderupk
IBM Developer

Future of Serverless ?

@lidderupk
IBM Developer

IBM Code Patterns

@lidderupk
IBM Developer
@lidderupk
IBM Developer

Apache OpenWhisk - simple action

Entry point

JsonObject In

JsonObject Out

@lidderupk
IBM Developer

JsonObject In

Fat JAR

Apache OpenWhisk - sample pom.xml

@lidderupk
IBM Developer

Apache OpenWhisk - make jar

@lidderupk
IBM Developer

Apache OpenWhisk - Runtime Exception

@lidderupk
IBM Developer

Apache OpenWhisk (py)

Entry point 

Dictionary

Dictionary

@lidderupk
IBM Developer

OpenWhisk

@lidderupk
IBM Developer

IBM Cloud Function

@lidderupk
IBM Developer

IBM Cloud Functions

@lidderupk
IBM Developer

Example - Banking App

@lidderupk
IBM Developer

More Examples

@lidderupk
IBM Developer

1

2

3

4

Apache OpenWhisk (java)

@lidderupk
IBM Developer

Apache OpenWhisk (tail log)

@lidderupk
IBM Developer

Apache OpenWhisk (js)

1

2

3

4

5

@lidderupk
IBM Developer

Apache OpenWhisk (py)

@lidderupk
IBM Developer

Serverless-short

By Upkar Lidder

Serverless-short

  • 265
Loading comments...

More from Upkar Lidder