SlideShare a Scribd company logo
1
Alex Glikson, IBM Research
June 29th, 2017
http://openwhisk.org/
with Apache OpenWhisk
Serverless IoT Applications
https://openwhisk-team.slack.com/
#openwhisk
on IBM Bluemix
https://console.bluemix.net/openwhisk/
2
Session Topics
1. Overview of the Serverless Paradigm and Apache OpenWhisk
2. The Internet of Things (IoT) and IoT Applications
3. Serverless Application Patterns for the IoT
3
1. Overview of the Serverless Paradigm
and Apache OpenWhisk
4
Many Cloud providers offer some form of Serverless framework
Amazon
AWS Lambda Azure Functions
Microsoft
Cloud Functions
Google
Functions
Iron.io Brocade
Apache OpenWhisk offers:
• Apache Software Foundation (ASF)
• True community-driven open source (Apache 2 License)
• Proven on IBM’s Bluemix Cloud Platform
• Exact same code in open source
others …
5
Apache OpenWhisk – Event-Trigger-Rule-Action Processing
OpenWhisk Platform
Action
NodeJS
Package
Feed
Package
Feed
Package
Feed
Data Stores
Instrumented
Machines
Rule
Rule
External
Service
Eco-System
Packages
Rule
P
Triggers
/ Rules
F
T
Social Media
R
A
Actions & Action Sequences
Action 2
Python
Action 3
Swift
Action 1
NodeJS
Action 1
Swift
Action 2
Docker
Sample Event
sources
3rd Party or
Self-Enabled
− REST APIs
− Message Queues
− Events
− Feeds
Events
6
Tooling
Apache OpenWhisk “Eco-System” Overview
ControllerRouter
Message
Bus
Key-Value
Store
Document
Store
Invokers
OpenWhisk “Core”
OpenWhisk “Catalog”
wskdeploy
(deployer + spec.)
debugger
IDE integ.
(xcode, vscode)
API Gateway
Application
“Samples”
Packages
Alarms
Kafka
Cloudant
External Resources
devtools
(Compose, Kube) Push
Notifications
“Template”
slackbot
GitHubSlackBot
openfridge
matos
Workshop, Tutorial
openwhisk.github.io (openwhisk.org)
Github
Ansible Deployments
darkvision
SDK
(nodejs)
CLI (wsk)
transit
7
Example: Monitoring Github comments
 Goals:
1. Watch for new comments in a given github.com repository
2. Save github.com events in a DB (Cloudant)
3. Provide REST API to access data in the DB (e.g., aggregate stats)
glikson/meetup/issues
/1
cloudant/
create-
document
cloudant/
list-
documents
issue_commen
t
meetup
prepGh2D
b
writeToDb
API Gateway
/meetup/v1/count
totalRows
http://ibm.biz/owmeetup
countInDb
2
3
4
7
1
5
6
8
Example: monitoring Github comments
http://ibm.biz/owmeetup
9
Serverless (and OpenWhisk) is applicable in many domains
10
2. The Internet of Things (IoT) and
IoT Applications
11
What is Internet of Things (IoT)?
 Internet of Things (IoT) applications:
• Rapidly emerging application development paradigm,
taking advantage of the ubiquitous connectivity and
programmability of physical devices:
1. Environment sensors (e.g., cities, private weather stations)
2. Consumer electronics (e.g., wearables, home appliances)
3. Industry (e.g., factories, agriculture, buildings)
4. Mobility (e.g., personal navigation, connected cars)
• Synergetic with the phenomenal adoption of smartphones
and the rapid growth of the enabling communication infrastructure,
providing commodity (low-cost, ubiquitous) connectivity
– 3G, 4G, 5G …
12
Characteristics of a Typical IoT Application
1. Big Data: large volume (e.g., # devices) and variety (e.g., message formats)
• Sensors (e.g., location, temperature, audio, motion)
• Actuators (e.g., valve, alarm, motor)
2. Devices are typically connected via Gateways
• Point of aggregation and control for devices in physical proximity
• Device-to-gateway communicating is often not TCP/IP-based (e.g., Bluetooth Low Energy)
3. Data often undergoes initial processing at the Gateway
• Motivated by latency, bandwidth or privacy constraints
• Often comprises simple real-time processing (e.g., property-based filtering, time-based aggregation)
– May trigger local actuation (e.g., based on pre-defined rules)
4. Data is shipped to a centralized cloud for storage and analytics
• Both (near) real-time and batch
• May trigger a feedback loop to the gateways
– E.g., actions triggered by a detected anomaly, updates of filtering thresholds
13
Example of IoT Application in IBM Bluemix
14
Opportunities for Serverless/FaaS in IoT
D
C
B
A
15
TRANSIT: Serverless Transformation of IoT Data-in-Motion
https://medium.com/openwhisk/serverless-transformation-of-iot-data-in-motion-with-openwhisk-272e36117d6c
16
Schematic end-to-end data flow
17
End-to-end data flow – 1 (Node-RED)
 Node-RED (simulated device):
• The ‘inject node’ triggers the flow at given intervals (e.g., every second).
• A sample event JSON is generated (by a custom ‘function node’).
• It is then aggregated using the ‘join’ node,
• compressed (using a custom function node), and
• sent to the Watson IoT Platform
(using MQTT with properly configured
orgId, device type, event type,
device id and security token).
18
End-to-end data flow – 2 (Watson IoT Platform)
 Watson IoT Platform (with historical data storage extension to Message Hub):
• Receives MQTT events from devices (after proper auth validation),
• Augments them (e.g., adding timestamp and context metadata) and
• Publishes in small batches to a Kafka topic (Message Hub).
19
End-to-end data flow – 3 (OpenWhisk)
 OpenWhisk (with custom transformation action):
• The Message Hub feed provider in OpenWhisk subscribes to messages in the iotp Kafka topic,
• Aggregates small batches of messages and
• Sends them as a payload to the OpenWhisk trigger, which in turn
• Triggers a sequence of actions
• Performing the message
transformation and
• Publishing the results to the
transformed Kafka topic
20
End-to-end data flow – 4 (Message Hub)
 Message Hub (bridge to Object Storage):
• Aggregates messages published to the transformed topic according to a specified policy (e.g., files of
up to 1 hour or 1MB of data), and
• Uploads the files to Object Storage according to the specified layout (e.g., applying date-based
partitioning).
21
TRANSIT: Serverless Transformation of IoT Data-in-Motion
https://medium.com/openwhisk/serverless-transformation-of-iot-data-in-motion-with-openwhisk-272e36117d6c
22
Example: Citizen Safety https://www.abilisense.com/
23
3. Serverless Application Patterns
for the IoT
24
Pattern #1: FaaS-based micro-services (decoupled, event-driven)
a) Business logic is decoupled into self-contained micro-services, implemented as stateless Functions
b) The business logic is triggered by IoT events (e.g., ingested via MQTT)
c) Functions communicate via events or state changes in dedicated persistent services (e.g., data stores)
Pattern #2: FaaS as a ‘glue’ integrating services in an event- or data-driven flow
a) The application is heavily relying on existing services (e.g., cognitive, data, analytics)
b) The ‘orchestration’ involves lightweight custom code, triggered by events or data
c) Each handler interacting with external services is encapsulated as a stateless short-living Function
Pattern #3: Acting upon outstanding conditions in stream processing
a) IoT events are ingested via a high-throughput channel (e.g. Message Bus)
b) Stateful stream processing is applied on incoming events (e.g., anomaly detection)
c) Upon detection of pre-defined conditions, a Function is triggered to apply custom business logic
Pattern #4: FaaS-enabled edge analytics
a) Business logic deployed on individual devices or gateways (e.g., due to latency, bandwidth, privacy)
b) Functions are portable across cloud and edge, enabling streamlined app development and operation
4 Serverless/FaaS Patterns for IoT Applications
25
Summary
 FaaS platforms enable rapid development of loosely-coupled event-driven applications
• Increased agility, manageability, elasticity
 OpenWhisk is a leading open source FaaS project
• Incubating under Apache, and available commercially by several vendors (including IBM)
 Serverless design patterns are still emerging, but there are many examples of leveraging
FaaS in IoT applications
• Pattern #1: FaaS-based micro-services (decoupled, event-driven)
• Pattern #2: FaaS as a ‘glue’ integrating services in an event- or data-driven flow
• Pattern #3: Acting upon outstanding conditions in stream processing
• Pattern #4: FaaS-enabled Edge Analytics (**work in progress**)
26
Live demo
Watson IoT Platform OpenWhisk
Environment
Sensor
Temperature
Above 20?
MQTT
Ingest
highTemp
trigger
actOnHighTemp
action
27
Questions?
Alex Glikson
https://medium.com/@glikson
http://slideshare.net/AlexGlikson/
@glikson
28
The Evolution of Cloud-Native Applications
Cloud Platforms
Infrastructure-as-a-Service (IaaS)
... Evolution Scale-out (“1.0”): Infrastructure-as-a-Service (IaaS)
• Architecture: layered into few application tiers (often 3-tier)
• Unit of deployment: Virtual Machine (VM), collection of VMs
• Connectivity: configuration-time routing between tiers
• Scaling: VM-based (auto-) scaling within each tier
HW
Micro Services (“2.0”): Container-as-a-Service (CaaS)
• Architecture: composition of small, self-contained services,
calling each other via a REST API
• Unit of deployment: group of containers comprising a service
• Connectivity: run-time service discovery and routing
• Scaling: container-based auto-scaling of each micro-service
Function-as-a-Service (FaaS)
...
Serverless (“3.0”): Functions-as-a-Service (FaaS)
• Architecture: event-driven flow of single-tasked functions
• Unit of deployment: Functions, collection of functions
• Connectivity: de-coupled (e.g., via state changes/events)
• Scaling: per-request (with optimization of warm-up times)
Micro Services (CaaS)
...

More Related Content

PPTX
AWS User Group Meetup Berlin - Kay Lerch on Apache NiFi (2016-04-19)
PPTX
OpenStack and OpenDaylight Workshop: ONUG Spring 2014
PPTX
IoT Discovery GE: An Introduction
PPTX
IoT Discovery tutorial
PPTX
Apache Fink 1.0: A New Era for Real-World Streaming Analytics
PPTX
Building the Internet of Things with Thingsquare and Contiki - day 1, part 1
PPTX
Apache Flink: Real-World Use Cases for Streaming Analytics
PDF
Apache NiFi Meetup - Princeton NJ 2016
AWS User Group Meetup Berlin - Kay Lerch on Apache NiFi (2016-04-19)
OpenStack and OpenDaylight Workshop: ONUG Spring 2014
IoT Discovery GE: An Introduction
IoT Discovery tutorial
Apache Fink 1.0: A New Era for Real-World Streaming Analytics
Building the Internet of Things with Thingsquare and Contiki - day 1, part 1
Apache Flink: Real-World Use Cases for Streaming Analytics
Apache NiFi Meetup - Princeton NJ 2016

What's hot (20)

PDF
Apricot2017 Request tracing in distributed environment
PPTX
IoT Workshop Nashville
PDF
Building Streaming Data Applications Using Apache Kafka
PDF
Mastering OpenStack - Episode 13 - Network Design
PDF
Hands-On Deep Dive with MiniFi and Apache MXNet
PPTX
Overview of Apache Fink: the 4 G of Big Data Analytics Frameworks
PPTX
Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
PDF
Deep learning on HDP 2018 Prague
PPT
Apache Flink Crash Course by Slim Baltagi and Srini Palthepu
PDF
Anaconda and PyData Solutions
PDF
Neutron high availability open stack architecture openstack israel event 2015
PDF
Maximilian Michels - Flink and Beam
PDF
Zoltán Zvara - Advanced visualization of Flink and Spark jobs

PDF
Reliable and Scalable Data Ingestion at Airbnb
PDF
What's new in OpenStack Liberty
PDF
Introduction to data flow management using apache nifi
PPTX
Omid: scalable and highly available transaction processing for Apache Phoenix
PDF
Next-Gen DDoS Detection
PPTX
OpenDaylight Netvirt and Neutron - Mike Kolesnik, Josh Hershberg - OpenStack ...
PPTX
Ted Dunning - Keynote: How Can We Take Flink Forward?
Apricot2017 Request tracing in distributed environment
IoT Workshop Nashville
Building Streaming Data Applications Using Apache Kafka
Mastering OpenStack - Episode 13 - Network Design
Hands-On Deep Dive with MiniFi and Apache MXNet
Overview of Apache Fink: the 4 G of Big Data Analytics Frameworks
Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
Deep learning on HDP 2018 Prague
Apache Flink Crash Course by Slim Baltagi and Srini Palthepu
Anaconda and PyData Solutions
Neutron high availability open stack architecture openstack israel event 2015
Maximilian Michels - Flink and Beam
Zoltán Zvara - Advanced visualization of Flink and Spark jobs

Reliable and Scalable Data Ingestion at Airbnb
What's new in OpenStack Liberty
Introduction to data flow management using apache nifi
Omid: scalable and highly available transaction processing for Apache Phoenix
Next-Gen DDoS Detection
OpenDaylight Netvirt and Neutron - Mike Kolesnik, Josh Hershberg - OpenStack ...
Ted Dunning - Keynote: How Can We Take Flink Forward?
Ad

Similar to Serverless, IoT and OpenWhisk (20)

PPT
IBM Bluemix OpenWhisk: Serverless Conference 2016, London, UK: The Future of ...
PPTX
From Device to Data Center to Insights: Architectural Considerations for the ...
PDF
Going Serverless with OpenWhisk
PDF
From Device to Data Center to Insights
PPTX
Splunk Discovery: Warsaw 2018 - Getting Data In
PPTX
M0339_v1_6977127809 (1).pptx
PPTX
Application and Network Orchestration using Heat & Tosca
PDF
Introduction to FreeSWITCH
PDF
Open stack ocata summit enabling aws lambda-like functionality with openstac...
PDF
End-to-end IoT solutions with Java and Eclipse IoT
PPTX
Integrating Things and the smart mobile phone capabilities
PPTX
Manta Unleashed BigDataSG talk 2 July 2013
PDF
OCCIware@CloudExpoLondon2017 - an extensible, standard XaaS Cloud consumer pl...
PDF
Extensible and Standard-based XaaS Platform To Manage Everything in The Cloud...
PDF
Test Execution Infrastructure for IoT Quality analysis
PPTX
State of the Container Ecosystem
PDF
Introduction to Apache Mesos and DC/OS
PPT
Avoiding cloud lock-in
PDF
C418 - Build, Deploy and Manage Your First Open Pattern with PureApplication ...
PPTX
BIOIT14: Deploying very low cost cloud storage technology in a traditional re...
IBM Bluemix OpenWhisk: Serverless Conference 2016, London, UK: The Future of ...
From Device to Data Center to Insights: Architectural Considerations for the ...
Going Serverless with OpenWhisk
From Device to Data Center to Insights
Splunk Discovery: Warsaw 2018 - Getting Data In
M0339_v1_6977127809 (1).pptx
Application and Network Orchestration using Heat & Tosca
Introduction to FreeSWITCH
Open stack ocata summit enabling aws lambda-like functionality with openstac...
End-to-end IoT solutions with Java and Eclipse IoT
Integrating Things and the smart mobile phone capabilities
Manta Unleashed BigDataSG talk 2 July 2013
OCCIware@CloudExpoLondon2017 - an extensible, standard XaaS Cloud consumer pl...
Extensible and Standard-based XaaS Platform To Manage Everything in The Cloud...
Test Execution Infrastructure for IoT Quality analysis
State of the Container Ecosystem
Introduction to Apache Mesos and DC/OS
Avoiding cloud lock-in
C418 - Build, Deploy and Manage Your First Open Pattern with PureApplication ...
BIOIT14: Deploying very low cost cloud storage technology in a traditional re...
Ad

More from Alex Glikson (8)

PDF
DevOpsDaysTLV24 - Spot Workload Optimization ML.pdf
PPTX
AWS Re:Invented
PPTX
Serverless Compute Platforms on Kubernetes
PPTX
From chroot to Docker to Kubernetes
PDF
Cloud-Native Application and Kubernetes
PDF
Mixing bare-metal and virtualized workloads on OpenStack - 2014
PDF
Container-Based Platforms and Kubernetes
PDF
The Serverless Paradigm, OpenWhisk and FIWARE
DevOpsDaysTLV24 - Spot Workload Optimization ML.pdf
AWS Re:Invented
Serverless Compute Platforms on Kubernetes
From chroot to Docker to Kubernetes
Cloud-Native Application and Kubernetes
Mixing bare-metal and virtualized workloads on OpenStack - 2014
Container-Based Platforms and Kubernetes
The Serverless Paradigm, OpenWhisk and FIWARE

Recently uploaded (20)

DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Modernizing your data center with Dell and AMD
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPT
Teaching material agriculture food technology
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
MYSQL Presentation for SQL database connectivity
The AUB Centre for AI in Media Proposal.docx
NewMind AI Weekly Chronicles - August'25 Week I
The Rise and Fall of 3GPP – Time for a Sabbatical?
Big Data Technologies - Introduction.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Modernizing your data center with Dell and AMD
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Spectral efficient network and resource selection model in 5G networks
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Chapter 3 Spatial Domain Image Processing.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Dropbox Q2 2025 Financial Results & Investor Presentation
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Teaching material agriculture food technology
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Per capita expenditure prediction using model stacking based on satellite ima...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
NewMind AI Monthly Chronicles - July 2025
MYSQL Presentation for SQL database connectivity

Serverless, IoT and OpenWhisk

  • 1. 1 Alex Glikson, IBM Research June 29th, 2017 http://openwhisk.org/ with Apache OpenWhisk Serverless IoT Applications https://openwhisk-team.slack.com/ #openwhisk on IBM Bluemix https://console.bluemix.net/openwhisk/
  • 2. 2 Session Topics 1. Overview of the Serverless Paradigm and Apache OpenWhisk 2. The Internet of Things (IoT) and IoT Applications 3. Serverless Application Patterns for the IoT
  • 3. 3 1. Overview of the Serverless Paradigm and Apache OpenWhisk
  • 4. 4 Many Cloud providers offer some form of Serverless framework Amazon AWS Lambda Azure Functions Microsoft Cloud Functions Google Functions Iron.io Brocade Apache OpenWhisk offers: • Apache Software Foundation (ASF) • True community-driven open source (Apache 2 License) • Proven on IBM’s Bluemix Cloud Platform • Exact same code in open source others …
  • 5. 5 Apache OpenWhisk – Event-Trigger-Rule-Action Processing OpenWhisk Platform Action NodeJS Package Feed Package Feed Package Feed Data Stores Instrumented Machines Rule Rule External Service Eco-System Packages Rule P Triggers / Rules F T Social Media R A Actions & Action Sequences Action 2 Python Action 3 Swift Action 1 NodeJS Action 1 Swift Action 2 Docker Sample Event sources 3rd Party or Self-Enabled − REST APIs − Message Queues − Events − Feeds Events
  • 6. 6 Tooling Apache OpenWhisk “Eco-System” Overview ControllerRouter Message Bus Key-Value Store Document Store Invokers OpenWhisk “Core” OpenWhisk “Catalog” wskdeploy (deployer + spec.) debugger IDE integ. (xcode, vscode) API Gateway Application “Samples” Packages Alarms Kafka Cloudant External Resources devtools (Compose, Kube) Push Notifications “Template” slackbot GitHubSlackBot openfridge matos Workshop, Tutorial openwhisk.github.io (openwhisk.org) Github Ansible Deployments darkvision SDK (nodejs) CLI (wsk) transit
  • 7. 7 Example: Monitoring Github comments  Goals: 1. Watch for new comments in a given github.com repository 2. Save github.com events in a DB (Cloudant) 3. Provide REST API to access data in the DB (e.g., aggregate stats) glikson/meetup/issues /1 cloudant/ create- document cloudant/ list- documents issue_commen t meetup prepGh2D b writeToDb API Gateway /meetup/v1/count totalRows http://ibm.biz/owmeetup countInDb 2 3 4 7 1 5 6
  • 8. 8 Example: monitoring Github comments http://ibm.biz/owmeetup
  • 9. 9 Serverless (and OpenWhisk) is applicable in many domains
  • 10. 10 2. The Internet of Things (IoT) and IoT Applications
  • 11. 11 What is Internet of Things (IoT)?  Internet of Things (IoT) applications: • Rapidly emerging application development paradigm, taking advantage of the ubiquitous connectivity and programmability of physical devices: 1. Environment sensors (e.g., cities, private weather stations) 2. Consumer electronics (e.g., wearables, home appliances) 3. Industry (e.g., factories, agriculture, buildings) 4. Mobility (e.g., personal navigation, connected cars) • Synergetic with the phenomenal adoption of smartphones and the rapid growth of the enabling communication infrastructure, providing commodity (low-cost, ubiquitous) connectivity – 3G, 4G, 5G …
  • 12. 12 Characteristics of a Typical IoT Application 1. Big Data: large volume (e.g., # devices) and variety (e.g., message formats) • Sensors (e.g., location, temperature, audio, motion) • Actuators (e.g., valve, alarm, motor) 2. Devices are typically connected via Gateways • Point of aggregation and control for devices in physical proximity • Device-to-gateway communicating is often not TCP/IP-based (e.g., Bluetooth Low Energy) 3. Data often undergoes initial processing at the Gateway • Motivated by latency, bandwidth or privacy constraints • Often comprises simple real-time processing (e.g., property-based filtering, time-based aggregation) – May trigger local actuation (e.g., based on pre-defined rules) 4. Data is shipped to a centralized cloud for storage and analytics • Both (near) real-time and batch • May trigger a feedback loop to the gateways – E.g., actions triggered by a detected anomaly, updates of filtering thresholds
  • 13. 13 Example of IoT Application in IBM Bluemix
  • 15. 15 TRANSIT: Serverless Transformation of IoT Data-in-Motion https://medium.com/openwhisk/serverless-transformation-of-iot-data-in-motion-with-openwhisk-272e36117d6c
  • 17. 17 End-to-end data flow – 1 (Node-RED)  Node-RED (simulated device): • The ‘inject node’ triggers the flow at given intervals (e.g., every second). • A sample event JSON is generated (by a custom ‘function node’). • It is then aggregated using the ‘join’ node, • compressed (using a custom function node), and • sent to the Watson IoT Platform (using MQTT with properly configured orgId, device type, event type, device id and security token).
  • 18. 18 End-to-end data flow – 2 (Watson IoT Platform)  Watson IoT Platform (with historical data storage extension to Message Hub): • Receives MQTT events from devices (after proper auth validation), • Augments them (e.g., adding timestamp and context metadata) and • Publishes in small batches to a Kafka topic (Message Hub).
  • 19. 19 End-to-end data flow – 3 (OpenWhisk)  OpenWhisk (with custom transformation action): • The Message Hub feed provider in OpenWhisk subscribes to messages in the iotp Kafka topic, • Aggregates small batches of messages and • Sends them as a payload to the OpenWhisk trigger, which in turn • Triggers a sequence of actions • Performing the message transformation and • Publishing the results to the transformed Kafka topic
  • 20. 20 End-to-end data flow – 4 (Message Hub)  Message Hub (bridge to Object Storage): • Aggregates messages published to the transformed topic according to a specified policy (e.g., files of up to 1 hour or 1MB of data), and • Uploads the files to Object Storage according to the specified layout (e.g., applying date-based partitioning).
  • 21. 21 TRANSIT: Serverless Transformation of IoT Data-in-Motion https://medium.com/openwhisk/serverless-transformation-of-iot-data-in-motion-with-openwhisk-272e36117d6c
  • 22. 22 Example: Citizen Safety https://www.abilisense.com/
  • 23. 23 3. Serverless Application Patterns for the IoT
  • 24. 24 Pattern #1: FaaS-based micro-services (decoupled, event-driven) a) Business logic is decoupled into self-contained micro-services, implemented as stateless Functions b) The business logic is triggered by IoT events (e.g., ingested via MQTT) c) Functions communicate via events or state changes in dedicated persistent services (e.g., data stores) Pattern #2: FaaS as a ‘glue’ integrating services in an event- or data-driven flow a) The application is heavily relying on existing services (e.g., cognitive, data, analytics) b) The ‘orchestration’ involves lightweight custom code, triggered by events or data c) Each handler interacting with external services is encapsulated as a stateless short-living Function Pattern #3: Acting upon outstanding conditions in stream processing a) IoT events are ingested via a high-throughput channel (e.g. Message Bus) b) Stateful stream processing is applied on incoming events (e.g., anomaly detection) c) Upon detection of pre-defined conditions, a Function is triggered to apply custom business logic Pattern #4: FaaS-enabled edge analytics a) Business logic deployed on individual devices or gateways (e.g., due to latency, bandwidth, privacy) b) Functions are portable across cloud and edge, enabling streamlined app development and operation 4 Serverless/FaaS Patterns for IoT Applications
  • 25. 25 Summary  FaaS platforms enable rapid development of loosely-coupled event-driven applications • Increased agility, manageability, elasticity  OpenWhisk is a leading open source FaaS project • Incubating under Apache, and available commercially by several vendors (including IBM)  Serverless design patterns are still emerging, but there are many examples of leveraging FaaS in IoT applications • Pattern #1: FaaS-based micro-services (decoupled, event-driven) • Pattern #2: FaaS as a ‘glue’ integrating services in an event- or data-driven flow • Pattern #3: Acting upon outstanding conditions in stream processing • Pattern #4: FaaS-enabled Edge Analytics (**work in progress**)
  • 26. 26 Live demo Watson IoT Platform OpenWhisk Environment Sensor Temperature Above 20? MQTT Ingest highTemp trigger actOnHighTemp action
  • 28. 28 The Evolution of Cloud-Native Applications Cloud Platforms Infrastructure-as-a-Service (IaaS) ... Evolution Scale-out (“1.0”): Infrastructure-as-a-Service (IaaS) • Architecture: layered into few application tiers (often 3-tier) • Unit of deployment: Virtual Machine (VM), collection of VMs • Connectivity: configuration-time routing between tiers • Scaling: VM-based (auto-) scaling within each tier HW Micro Services (“2.0”): Container-as-a-Service (CaaS) • Architecture: composition of small, self-contained services, calling each other via a REST API • Unit of deployment: group of containers comprising a service • Connectivity: run-time service discovery and routing • Scaling: container-based auto-scaling of each micro-service Function-as-a-Service (FaaS) ... Serverless (“3.0”): Functions-as-a-Service (FaaS) • Architecture: event-driven flow of single-tasked functions • Unit of deployment: Functions, collection of functions • Connectivity: de-coupled (e.g., via state changes/events) • Scaling: per-request (with optimization of warm-up times) Micro Services (CaaS) ...

Editor's Notes

  • #2: Hello, my name is Alex Glikson, I work for IBM Research in Israel, and I am going to talk about Serverless IoT Applications with Apache OpenWhisk.
  • #3: During this session, I will start by giving a brief overview of the Serverless paradigm, and specifically OpenWhisk. Then, I will talk about the Internet of Things and the applications targeting this domain. And finally, the main topic of this session is Serverless application patterns, applicable to the domain of the internet of things.
  • #4: So, the first topic is an overview of the Serverless paradigm and the Apache OpenWhisk project.
  • #5: As you probably know, the Serverless paradigm became very popular in the last 2-3 years, and there are multiple commercial offerings in this space, from IBM, Amazon, Microsoft, Google, and others. In addition, there has been a movement towards an open source Serverless platform, which resulted in creation of the OpenWhisk project, which is now under incubation at the Apache Software Foundation. InfoWorld, May 2017, “Get functional! 5 open source frameworks for serverless computing" http://www.infoworld.com/article/3193119/open-source-tools/get-functional-5-open-source-frameworks-for-serverless-computing.html https://aws.amazon.com/lambda/ https://github.com/iron-io/functions
  • #6: Let’s briefly review the architecture of OpenWhisk. On the left, you can see a collection of event sources, such as data stores, social media or physical equipment sending events. Those events are organized in feeds, that generate triggers. Then a trigger can be associated by rules with one or more actions. An action is really the heart of OpenWhisk, comprising a single-tasked function, that can be developed in pretty much any programming language. Actions can perform a standalone computation, or they can interact with other services – either deployed in the context of the same application, or 3rd party services. Every time a new event is detected, actions associated with this event are instantiated in containers, invoked, and then released. For optimization purposes, OpenWhisk maintains pools of so-called ‘warm’ containers, often reducing the action invocation time to just few milliseconds.
  • #7: Besides the ‘core’ OpenWhisk components that support the provisioning and life-cycle of triggers, actions, and related artifacts, there is also a large and growing open source ecosystem. It includes various developer tools, a library of packages that make it easy to integrate with common services such as Kafka or Github, and many more.
  • #8: Let’s take a look at a simple Serverless application implemented with OpenWhisk. We are going to monitor a particular issue in a github repository, save the incoming comments in a database in the cloud, and provide a REST-based query interface, applying some custom aggregation logic. <click> The implementation comprises 7 artifacts: 1 - a database instance 2 - an OpenWhisk trigger, listening for github notifications 3 - An action writing to the database, called ‘writeToDb’. In fact, this is a sequence of two actions – our custom action, number 4, performing some simple JSON transformation, and the standard ‘create-document’ action from the Cloudant package that actually writes to the database 5 is an action performing simple aggregation of the data stored in the database. In this case – just counting the comments, called countInDb. It also comprises a sequence of two actions – a standard one, list-documents, from the Cloudant package, and our custom action, number 6, called totalRows. Finally, 7 is the API gateway configuration, mapping an external REST api, meetup/v1/count, to the countInDb action. By the way, the application is up and running, so you can try it out by adding a comment and going to the URL linked on the slide.
  • #9: Now, the actual code needed to make this work is really tiny – about 10 lines of javascript code for the two actions, plus about 10 CLI commands for the setup. That’s it!
  • #10: Beyond the simple example we just saw, the Serverless paradigm, and OpenWhisk in particular, can be applied in many different application domains – Cognitive, internet of things, Mobile, and many others. <click> In the session we are going to focus on applications in the IoT domain.
  • #11: Now let’s briefly talk about the Internet of Things, or IoT, in general, and applications targeting IoT in particular.
  • #12: Let’s start with the concept of ‘internet of things’ itself. What is ‘internet of things’? It is essentially an attempt to capture an extensive trend in the industry, where physical devices, or ‘things’, become connected and programmable. For example, you can think of environment sensors, measuring temperature or air pollution in different locations around the world, and reporting those measurements over the Internet. Or, it could be a smart bracelet that measures your fitness activity, and sends the data to your mobile phone, where it can be analyzed and visualized. In the industrial sector, it could be a piece of mechanical equipment controlled by a computer, collecting thousands of different metrics that can be used for fault detection or predictive maintenance. Another example is a personal navigation device, such as a mobile phone, or maybe a connected car, interacting with other cars in a collaborative driving or autonomous vehicle scenarios. Emergence of such applications has been significantly accelerated by the broad adoption of smart phones, and the mobile infrastructure that enables it, making connectivity a real commodity, almost anywhere in the world. images: - https://www.i-scoop.eu/internet-of-things-guide/ - https://datafloq.com/read/7-trends-of-internet-of-things-in-2017/2530
  • #13: Now let’s talk a bit about main characteristics of IoT applications. First, IoT applications often have so-called Big Data properties, due to large volumes of devices and data that they collect, as well as large variety of data, that requires custom processing of different kinds of data. Secondly, devices are typically connected to the Internet via Gateways rather than directly. Those gateways are responsible for controlling the devices and for collecting and aggregating events and data. Third, data often undergoes initial processing at the gateway. For example, this could be due to latency, bandwidth, or privacy constraints. Gateways often perform simple real-time stream processing, such as property-based filtering, or time-based aggregation. Finally, data is often shipped to a centralized cloud for storage and analytics, which in turn could result in communication back to the device, to perform an action or to update thresholds used for stream processing.
  • #14: Let’s take a look at an example architecture of an IoT application hosted in IBM Bluemix. As you can see on the diagram, there are devices and gateways on the left, interacting with the Watson IoT Platform in the Cloud. From there, a dedicated bridge forwards the messages to Message Hub – a hosted Kafka offering in Bluemix. The data can flow from Message Hub to multiple other services, such as Stream Analytics, used for real-time processing of IoT event streams, or to Object Storage, which is ideal for long-term storage and batch analytics of historical data. Then the results of stream or batch analytics can be visualized in Jupyter Notebooks, which are part of the Data Science Experience offering. Of course, this is just an example, and there might be many other ways to ingest, process, store and analyze IoT data.
  • #15: Now, how can we take advantage of OpenWhisk in such an architecture? Here are few ideas. A: we can use OpenWhisk to perform transformation on data-in-motion, before it is archived in Object Storage. For example, we could apply format conversion or indexing, to make the data in object storage more easily accessible for analytics. B: After the data is stored, OpenWhisk can be used for ETL-style processing, organizing it in different ways for analytics, or augmenting the data with other data sources. C: In stream analytics, OpenWhisk can be used to perform custom actions upon certain conditions detected by stream processing. For example, it could be used to trigger a feedback to the device, sent through the IoT Platform. And finally D: serverless functions can be useful at the edge, making it possible to handle the data-in-motion processing in a hollistics and unified way across the cloud and the edge.
  • #16: Let’s explore in detail the first option – transformation of the data-in-motion before it is stored in Object Storage. The way it is implemented is by having two Kafka topics – the original topic used for messages arriving from the IoT Platform, and a new one, for transformed messages, which are then persisted in Object Storage, as usual. So, the “magic” happens between those two topics. In a nutshell – the idea is to define an OpenWhisk trigger that would be fired when a new batch of messages is available on the original topic, triggering the transformation action, which would also write to the destination topic. Now let’s explore the end-to-end flow in more detail.
  • #17: Here you can see an illustration of the data flow in this example – starting from the sensor, to the gateway where it is aggregated and sent to the cloud, where it is augmented, transformed, organized and persisted.
  • #18: The first part of the pipeline happens in Node-RED, which can be used to implement a Do-It-Yourself-style gateway. The ‘inject node’ triggers the flow at given intervals (e.g., every second). A sample event JSON is generated (by a custom ‘function node’). It is then aggregated using the ‘join’ node, compressed (using a custom function node), and sent to the Watson IoT Platform (using MQTT with properly configured orgId, device type, event type, device id and security token).
  • #19: Then the Watson IoT Platform receives MQTT events from devices (after proper auth validation), augments them (e.g., adding timestamp and context metadata) and publishes in small batches to a Kafka topic (Message Hub).
  • #20: The third, and the most interesting part happens in OpenWhisk, where the custom transformation happens. The Message Hub feed provider in OpenWhisk subscribes to messages in the iotp Kafka topic, aggregates small batches of messages and sends them as a payload to the OpenWhisk trigger, which in turn triggers a sequence of actions performing the message transformation and publishing the results to the transformed Kafka topic. You can see here the code in java-script implementing this action. It is rather simple, just 30 lines of code. Yet, the mechanism as a whole is extremely powerful, making it easy to apply any kind of custom transformation on the data.
  • #21: Finally, the last part of the pipeline happens Message Hub, taking advantage of the bridge to Object Storage. It aggregates messages published to the transformed topic according to a specified policy (e.g., files of up to 1 hour or 1MB of data), and uploads the files to Object Storage according to the specified layout (e.g., applying date-based partitioning).
  • #22: To summarize, in this example OpenWhisk is used as part of a IoT data processing pipeline – essentially as a stateless micro-service interacting with a persistent service (Kafka), triggered by changes in that service.
  • #23: Now let’s take a look at a real-life architecture coming from Abilisense - a company that uses OpenWhisk in Bluemix. The essence of their solution is to monitor audio data collected using special hardware devices, to identify anomalies or certain “important” conditions, and to generate alerts (typically to a mobile phone). It is useful in several application domains, such as baby care, when you want to know that your baby is crying at night, or property care, when you want to know that, for example, some is making noises in your apartment while you are at work. The data collection is performed by the Abilisense device, shown at the upper-left side of the diagram. The devices sends audio data to object storage, and MQTT events to the Watson IoT Platform. These events trigger an OpenWhisk action, that orchestrates the processing workflow. In particular, it passes the data from object storage to a sound processing micro-service , that detects certain anomalies and conditions. If detected, OpenWhisk triggers a notification mechanism, which could send alerts back to the device, or to a mobile phone, or event contact authorities if their intervention is required. In addition, the sound data is continuously fed into a machine learning micro-service, which constantly improves the sound detection algorithms used in real-time. Moreover, OpenWhisk is used to pull in additional data sources which may affect the accuracy of the sound detection. For example, weather conditions – whether it is raining at a particular location. To summarize, OpenWhisk actions in this example are triggered by IoT events arriving from Abilisense devices, and are used primarily as a ‘glue’ between various micro-services which are part of the application itself, and also to call out to external services. Moreover, it is used as a mechanism to act upon certain conditions or anomalies detected by the business logic.
  • #24: Now let’s try formalizing a bit the patterns around Serverless for the IoT.
  • #25: We can identify 4 patterns capturing best practices of using Serverless or FaaS in IoT. #1: FaaS-based micro-services. Like with regular micro-services, the business logic of the application is decoupled into self-contained portions – but now the unit of deployment is a Function. Those Functions are triggered by IoT events, and the communication between them is also typically done using events. In many cases these are change events generated by persistent services, such as a data store used to maintain state of IoT devices. Pattern #2: FaaS can be used as a ‘glue’ integrating services in an event- or data-driven flow. You can notice certain similarity to the first pattern, but here the scope is not limited to data services keeping state of the IoT application. It could be pretty much any service accessible programmatically – such as speech recognition, visual analytics, or machine learning. Most of the business logic is captured in those services, and FaaS is used to integrate them together, in an agile, elastic and efficient manner. Pattern #3: FaaS can be used to act upon outstanding conditions in stream processing. For example, we could have a high-throughput stream of IoT events comprising the speed of cars on the road. Stream processing can be used to determine the number of cars in a certain road segment. If certain threshold is passed, FaaS can be used to trigger reconfiguration of traffic lights, to avoid traffic jam. This reconfiguration is even-driven, and if implemented as a regular long-running service, it would have been idle most of the time. The last pattern, #4, targets Edge environments, such as IoT gateways, rather than Cloud. Here, the business logic of the IoT application spans the cloud and the edge, and FaaS can be used to unify event-based processing capabilities. This pattern is the newest one, and there is lots of ongoing research to figure out how to do it right.
  • #26: To summarize: FaaS platforms enable rapid development of loosely-coupled event-driven application - increasing agility, manageability, elasticity. OpenWhisk is a leading open source FaaS project, collaboratively developed by IBM and other vendors under the governance of the Apache Software Foundation. FaaS is a new field, so best practices and design patterns are still emerging – but there are several patterns that can be already identified for specific application domains, such as IoT. And we briefly discussed 4 such patterns.
  • #28: That’s all for today, I will be happy to answer questions, and feel free to take a look and my blogs and presentations for further details.