Developing
Serverless Applications
with Apache OpenWhiskNiklas Heidloff
Developer Advocate, IBM
@nheidloff
heidloff.net
April 2018
Agenda Disclaimers
1)  Introduction to Serverless
2)  Development of
Serverless Functions
3)  Development of
Serverless Applications
@nheidloff
heidloff.net
Most information in this session
is about Apache OpenWhisk,
some features are only available
in IBM Cloud Functions –
indicated on slides via icons
Focus is on development
related topics, not on operations
Serverless
“Serverless computing is a cloud computing execution model in
which the cloud provider dynamically manages the allocation of
machine resources. Pricing is based on the actual amount of
resources consumed by an application.” (via Wikipedia)
Sample scenario: Serverless Web Application
@nheidloff
heidloff.net
Use Cases
@nheidloff
heidloff.net
Volatile and/or event-driven workload that can be split in smaller
short-running pieces
APIs
Data processing
Event processing
Apache OpenWhisk
“Apache OpenWhisk is a serverless, open source cloud platform
that executes functions in response to events without developer
concern for managing the lifecycle or operations of the
containers that execute the code.” (via Apache)
Supported runtimes: Node.js, Python, PHP, Swift and Docker
Deployment: On-premises or in the cloud
@nheidloff
heidloff.net
Apache OpenWhisk
Supported runtimes: Node.js, Python, PHP, Swift and Docker
Development
Local development via standard tooling and IDEs
Web tooling provided by cloud providers
@nheidloff
heidloff.net
JavaScript Function
@nheidloff
heidloff.net
Asynchronous JavaScript Function
@nheidloff
heidloff.net
JavaScript Function with Dependencies
@nheidloff
heidloff.net
JavaScript Function in Docker
@nheidloff
heidloff.net
Debugging JavaScript Functions in Docker
@nheidloff
heidloff.net
Function Invocation via CLI
@nheidloff
heidloff.net
Function Invocation via HTTP
@nheidloff
heidloff.net
Function Invocation via HTTP
@nheidloff
heidloff.net
API Management
@nheidloff
heidloff.net
API Management
@nheidloff
heidloff.net
API Management
@nheidloff
heidloff.net
API Management
@nheidloff
heidloff.net
Serverless Applications
@nheidloff
heidloff.net
Development of single functions is easy, but how do you build
cloud-native applications with lots of functions?
Functions are stateless, applications have state
“There is no such thing as a stateless architecture, it’s just
someone else’s problem” (via Jonas Bonér)
OpenWhisk Conductor Functions
@nheidloff
heidloff.net
Conductor functions allow invoking a series of functions
Composer
Composer is a new programming model for composing
functions, built on Apache OpenWhisk
Declarative and programmatic
approach to define sophisticated
flows between functions in
cloud-native apps
State management between
‘stateless’ functions based on
OpenWhisk Conductor Actions@nheidloff
heidloff.net
Sample Application: Send Notification
1)  Application is triggered with a person id and a subject
2)  First function returns the profile for the specific user with an
email address and optionally a phone number
3)  If the profile has a phone number, a text message is sent,
otherwise an email
@nheidloff
heidloff.net
Sample Application
@nheidloff
heidloff.net
Visualized in IBM
Cloud Functions Shell
Sample Application
Polyglot
JavaScript
TypeScript
Java
Kotlin
@nheidloff
heidloff.net
Sample Invocation via CLI
@nheidloff
heidloff.net
Invocation Results
@nheidloff
heidloff.net
Visualized in IBM
Cloud Functions Shell
Session Flow
@nheidloff
heidloff.net
Visualized in IBM
Cloud Functions Shell
JavaScript Function in Visual Studio Code
@nheidloff
heidloff.net
TypeScript Function in Visual Studio Code
@nheidloff
heidloff.net
Java Function in Eclipse
@nheidloff
heidloff.net
Kotlin Function in IntelliJ IDEA
@nheidloff
heidloff.net
Composer Application
@nheidloff
heidloff.net
Composer Programming Constructs
@nheidloff
heidloff.net
Activity
@nheidloff
heidloff.net
Summary
@nheidloff
heidloff.net
Apache OpenWhisk is an open source serverless platform
OpenWhisk functions can be developed via Docker
OpenWhisk can used in the cloud and on-premises
IBM Cloud Functions is based on OpenWhisk and adds ...
API management
Composer to build cloud-native applications
Try out OpenWhisk and Cloud Functions: http://ibm.biz/nheidloff
Resources
Sample Application
https://github.com/nheidloff/openwhisk-polyglot
OpenWhisk
https://openwhisk.apache.org
https://github.com/nheidloff/openwhisk-debug-nodejs
IBM Cloud Functions
http://ibm.biz/nheidloff
https://github.com/ibm-functions/composer
@nheidloff
heidloff.net

Developing Serverless Applications with Apache OpenWhisk