SlideShare uma empresa Scribd logo
1 de 19
Event Sourcing for the IoT
Mike Blackstock
Sense Tecnic Systems, Inc.
Overview
• What is the IoT today?
• CRUD to Event Sourcing for the IoT
• Role of Node-RED in IoT systems
• Demonstrate Node-RED and FRED service for IoT app development
The IoT Today - Fog Computing
• Sense the world
• Track assets in a supply chain
• Soil moisture levels in fields
• Data from factory floor
• Actuate to change it
• Control lighting
• HVAC system control
• Control Irrigation
• The number of devices far exceeds
users….
• Cloud to Fog
• data, compute, storage and apps
distributed across devices, gateways
and cloudhttps://erpinnews.com/fog-computing-vs-edge-computing
IoT Application Requirements
• Present real world data to end users for decision making
• Add intelligence, user control, system control
• Variety of protocols, standards & formats
• HTTP, MQTT, Websockets, CoAP, OPC, Modbus, Bluetooth, WiFi, LoRaWAN…
• Integration with a variety of services
• Enterprise systems, alerting systems, virtual ‘sensors’
• “Real time”
• Send an alert when a tank level is too high
• Turn on irrigation system when moisture too low
• Send SMS when taxi is about to arrive
• Access to historical data
• Time series charts in visualizations
• Historical analysis, recognizing patterns, learning
• Storage and compute in gateways and devices (fog)
• Reduce latency, storage, data rates, and work disconnected
Traditional CRUD Applications
• IoT apps often start by leveraging traditional
frameworks
• Model of data where we create records,
update them, delete them
• Model consists of users, things, information
about things
• Things and users communicate with the system
using a REST API for example.
Update
Presentation
Data Storage
Business Logic
Data Access
Query
Challenges
• Scale
• many things and high data rates
• Valuable historical data (events) may be lost
• An update from a user or a thing may trigger many operations
• checked for alert condition
• notification to a user
• displayed in a dashboard
• processed and sent to an enterprise system
• trigger an actuator
• count for a subscription
• Integrating things & services
Adding things
• Things could communicate via API
• New controllers or presentation
servers
• Requires real time input and output --
Websockets?
• Different protocols required
• E.g. how to support MQTT
• security and authentication schemes
• Historical data
• time series data stores.
• Business logic to process data may
be complex, not easy to scale up.
State Storage
Business Logic
State Data
Access
Query
Users
Update
API
Time Series
Storage
Time Series
Access
Presentation
Things
CQRS: Increase Scalability
• Command Query Responsibility Segregation
• different logic and data models used to
update/write vs. query/read side
• Split commands from query model to scale
independently.
• E.g. mobile app and web pages rendered
using query model
• User interaction updates command model
in write storage
• Changes communicated to read storage
model either by the database, or
communication between command and
query processes
Presentation
Domain
Logic
Write
Storage
Generate
Views
Read
Storage
Query
Generation
Commands Queries
Adding things
• In the IoT, both things and users are
updating the command model
• How do we scale up and change
thing interaction from user
interaction independently?
• What is the appropriate model for
the write storage?
• How/where can we make use of
time series storage?
Domain
Logic
Write
Storage
Generate
Views
Read
Storage
Query
Generation
Commands
API Presentation
UsersThings
Time
Series
Store
Event Sourcing
• Instance of CQRS where commands
validated and processed to create events
• Every state change (event) is captured
and stored in sequence in an Event Store.
• Other processes can subscribe to events.
• Characteristics
• History – for free
• Replay events to regenerate the current state
• Or any point in time
• Can ‘fix’ state, e.g. By reversing past events.
User Presentation
Process
Commands
Event
Store
Process
Events
State
Store
Commands
Events
Query
Generation
Published
Events
Queries
Event Sourcing for IoT
• Two main sources of events –
users and things
• Separate thing ‘presentation’
• scaled out independently
• often # things > users
• Separate thing command
processing and generation
• Tap event stream for
• external systems
• Thing actuation
• time series storage
Actuation
User Presentation
Process
Commands
Event
Store
Process
Events
State
Store
Commands
Events
Query
Generation
Thing Presentation
Process
Commands
Generate
Commands
External
Systems
Sensing
Things
Events
ThingsThings
Gateways Things
Time
Series
Store
External IoT
Systems
Summary and Open Questions
• Event Sourcing architecture
• Can scale “thing presentation” and command processing independently
• However CQRS and event sourcing is more complex
• Methodologies, toolkits, frameworks available to help (ask Adaptech!)
• Remaining Open Questions:
• How do we handle the huge variety of protocols, services needed for a
complete IoT solution?
• How can we quickly get systems up and running? Moving from prototype to
production, support testing and simulation?
• How can we process data on the edge in gateways and devices for Fog
computing?
Node-RED and FRED for Event Sourcing
• Visual data flow programming –
rapid development
• Flows, nodes, wires and messages
(events)
• Huge variety of protocols and
services
• Can deploy NR flows on edge
devices and the cloud (FRED)
Why Node-RED?
• Almost every “new” thing in the IoT has a different protocol, platform
API today.
• Complete solutions often require pulling together device protocols,
online services
• Too much time spent on things like how to access GPIO pins on
devices, access serial port, set up HTTP or TCP/UDP endpoints,
connect to MQTT broker, OAuth dance on an API, connect to OPC UA
server…
• Node-RED wraps these issues in “nodes”, and lets developers focus on
solution at hand. In our case, getting commands and events in and
out of our system.
Where does Node-RED
fit?
• Simple Dashboards
• Thing Integration
• Device and gateway processing
• External System Integration
• Designing and Prototyping
systems
• Testing and simulation
User Presentation
Process
Commands
Event
Store
Process
Events
State
Store
Commands
Events
Query
Generation
Thing Presentation
Process
Commands
Generate
Commands
External
Systems
Things
Events
ThingsThings
Gateways Things
State
Store
External
IoT
Systems
FRED – Cloud-hosted Node-RED Demo
WIP: Event Sourcing with Node-RED
• Commands & Event processing
• Event Store integration
• REST API for User Commands & Queries
• Get latest state of things
• Send control commands
• MQTT interface for things
• Sensing
• Actuation
• Dashboard and Alerting
• Thing simulation
Summary
• IoT applications have unique characteristics
• Event Sourcing architectures are a natural fit for IoT applications
• Node-RED and FRED are useful tools
• Thing presentation & integration
• service integration
• rapid prototyping
• Dashboards
• Testing & simulation
Thank you! Questions?
Thanks to Adaptech Solutions for invitation and support!
FRED Platform: https://fred.sensetecnic.com (free to try):
• Cloud-hosted Node-RED
• MQTT service
• InfluxDb time series storage
Node-RED: https://nodered.org/
mike@sensetecnic.com
@mblackstock

Mais conteúdo relacionado

Mais procurados

Apache Flink Training: DataStream API Part 1 Basic
 Apache Flink Training: DataStream API Part 1 Basic Apache Flink Training: DataStream API Part 1 Basic
Apache Flink Training: DataStream API Part 1 Basic
Flink Forward
 
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
confluent
 
Kafka/SMM Crash Course
Kafka/SMM Crash CourseKafka/SMM Crash Course
Kafka/SMM Crash Course
DataWorks Summit
 

Mais procurados (20)

Creating Connector to Bridge the Worlds of Kafka and gRPC at Wework (Anoop Di...
Creating Connector to Bridge the Worlds of Kafka and gRPC at Wework (Anoop Di...Creating Connector to Bridge the Worlds of Kafka and gRPC at Wework (Anoop Di...
Creating Connector to Bridge the Worlds of Kafka and gRPC at Wework (Anoop Di...
 
The Patterns of Distributed Logging and Containers
The Patterns of Distributed Logging and ContainersThe Patterns of Distributed Logging and Containers
The Patterns of Distributed Logging and Containers
 
Apache Kafka vs RabbitMQ: Fit For Purpose / Decision Tree
Apache Kafka vs RabbitMQ: Fit For Purpose / Decision TreeApache Kafka vs RabbitMQ: Fit For Purpose / Decision Tree
Apache Kafka vs RabbitMQ: Fit For Purpose / Decision Tree
 
Event Driven Architecture
Event Driven ArchitectureEvent Driven Architecture
Event Driven Architecture
 
Top 5 Event Streaming Use Cases for 2021 with Apache Kafka
Top 5 Event Streaming Use Cases for 2021 with Apache KafkaTop 5 Event Streaming Use Cases for 2021 with Apache Kafka
Top 5 Event Streaming Use Cases for 2021 with Apache Kafka
 
Combining Logs, Metrics, and Traces for Unified Observability
Combining Logs, Metrics, and Traces for Unified ObservabilityCombining Logs, Metrics, and Traces for Unified Observability
Combining Logs, Metrics, and Traces for Unified Observability
 
Top use cases for 2022 with Data in Motion and Apache Kafka
Top use cases for 2022 with Data in Motion and Apache KafkaTop use cases for 2022 with Data in Motion and Apache Kafka
Top use cases for 2022 with Data in Motion and Apache Kafka
 
Apache Flink Training: DataStream API Part 1 Basic
 Apache Flink Training: DataStream API Part 1 Basic Apache Flink Training: DataStream API Part 1 Basic
Apache Flink Training: DataStream API Part 1 Basic
 
Real-Life Use Cases & Architectures for Event Streaming with Apache Kafka
Real-Life Use Cases & Architectures for Event Streaming with Apache KafkaReal-Life Use Cases & Architectures for Event Streaming with Apache Kafka
Real-Life Use Cases & Architectures for Event Streaming with Apache Kafka
 
Juraci Paixão Kröhling - All you need to know about OpenTelemetry
Juraci Paixão Kröhling - All you need to know about OpenTelemetryJuraci Paixão Kröhling - All you need to know about OpenTelemetry
Juraci Paixão Kröhling - All you need to know about OpenTelemetry
 
Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018
 
Kafka Streams State Stores Being Persistent
Kafka Streams State Stores Being PersistentKafka Streams State Stores Being Persistent
Kafka Streams State Stores Being Persistent
 
How Prometheus Store the Data
How Prometheus Store the DataHow Prometheus Store the Data
How Prometheus Store the Data
 
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
 
Domain Driven Design
Domain Driven Design Domain Driven Design
Domain Driven Design
 
Venturing into Large Hadoop Clusters
Venturing into Large Hadoop ClustersVenturing into Large Hadoop Clusters
Venturing into Large Hadoop Clusters
 
Microservices Decomposition Patterns
Microservices Decomposition PatternsMicroservices Decomposition Patterns
Microservices Decomposition Patterns
 
Secrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on KubernetesSecrets of Performance Tuning Java on Kubernetes
Secrets of Performance Tuning Java on Kubernetes
 
Kafka/SMM Crash Course
Kafka/SMM Crash CourseKafka/SMM Crash Course
Kafka/SMM Crash Course
 
Prometheus in Practice: High Availability with Thanos (DevOpsDays Edinburgh 2...
Prometheus in Practice: High Availability with Thanos (DevOpsDays Edinburgh 2...Prometheus in Practice: High Availability with Thanos (DevOpsDays Edinburgh 2...
Prometheus in Practice: High Availability with Thanos (DevOpsDays Edinburgh 2...
 

Semelhante a CQRS and Event Sourcing for IoT applications

A Pragmatic Reference Architecture for The Internet of Things
A Pragmatic Reference Architecture for The Internet of ThingsA Pragmatic Reference Architecture for The Internet of Things
A Pragmatic Reference Architecture for The Internet of Things
Rick G. Garibay
 
Motadata brochure
Motadata brochureMotadata brochure
Motadata brochure
RajDodiya4
 

Semelhante a CQRS and Event Sourcing for IoT applications (20)

Monitoring and Scaling Redis at DataDog - Ilan Rabinovitch, DataDog
 Monitoring and Scaling Redis at DataDog - Ilan Rabinovitch, DataDog Monitoring and Scaling Redis at DataDog - Ilan Rabinovitch, DataDog
Monitoring and Scaling Redis at DataDog - Ilan Rabinovitch, DataDog
 
How to create custom dashboards in Elastic Search / Kibana with Performance V...
How to create custom dashboards in Elastic Search / Kibana with Performance V...How to create custom dashboards in Elastic Search / Kibana with Performance V...
How to create custom dashboards in Elastic Search / Kibana with Performance V...
 
A Pragmatic Reference Architecture for The Internet of Things
A Pragmatic Reference Architecture for The Internet of ThingsA Pragmatic Reference Architecture for The Internet of Things
A Pragmatic Reference Architecture for The Internet of Things
 
Transforming Consumer Banking with a 100% Cloud-Based Bank (FSV204) - AWS re:...
Transforming Consumer Banking with a 100% Cloud-Based Bank (FSV204) - AWS re:...Transforming Consumer Banking with a 100% Cloud-Based Bank (FSV204) - AWS re:...
Transforming Consumer Banking with a 100% Cloud-Based Bank (FSV204) - AWS re:...
 
Build your First IoT Application with IBM Watson IoT
Build your First IoT Application with IBM Watson IoTBuild your First IoT Application with IBM Watson IoT
Build your First IoT Application with IBM Watson IoT
 
Cloud Experience: Data-driven Applications Made Simple and Fast
Cloud Experience: Data-driven Applications Made Simple and FastCloud Experience: Data-driven Applications Made Simple and Fast
Cloud Experience: Data-driven Applications Made Simple and Fast
 
Java in the Air: A Case Study for Java-based Environment Monitoring Stations
Java in the Air: A Case Study for Java-based Environment Monitoring StationsJava in the Air: A Case Study for Java-based Environment Monitoring Stations
Java in the Air: A Case Study for Java-based Environment Monitoring Stations
 
Best Practices for Streaming IoT Data with MQTT and Apache Kafka
Best Practices for Streaming IoT Data with MQTT and Apache KafkaBest Practices for Streaming IoT Data with MQTT and Apache Kafka
Best Practices for Streaming IoT Data with MQTT and Apache Kafka
 
Viele Autos, noch mehr Daten: IoT-Daten-Streaming mit MQTT & Kafka (Kai Waehn...
Viele Autos, noch mehr Daten: IoT-Daten-Streaming mit MQTT & Kafka (Kai Waehn...Viele Autos, noch mehr Daten: IoT-Daten-Streaming mit MQTT & Kafka (Kai Waehn...
Viele Autos, noch mehr Daten: IoT-Daten-Streaming mit MQTT & Kafka (Kai Waehn...
 
Best Practices for Streaming IoT Data with MQTT and Apache Kafka®
Best Practices for Streaming IoT Data with MQTT and Apache Kafka®Best Practices for Streaming IoT Data with MQTT and Apache Kafka®
Best Practices for Streaming IoT Data with MQTT and Apache Kafka®
 
Azure Application insights - An Introduction
Azure Application insights - An IntroductionAzure Application insights - An Introduction
Azure Application insights - An Introduction
 
Introduction to FIWARE Open Ecosystem
Introduction to FIWARE Open EcosystemIntroduction to FIWARE Open Ecosystem
Introduction to FIWARE Open Ecosystem
 
People Counting: Internet of Things in Motion at JavaOne 2013
People Counting: Internet of Things in Motion at JavaOne 2013People Counting: Internet of Things in Motion at JavaOne 2013
People Counting: Internet of Things in Motion at JavaOne 2013
 
Ibm_IoT_Architecture_and_Capabilities
Ibm_IoT_Architecture_and_CapabilitiesIbm_IoT_Architecture_and_Capabilities
Ibm_IoT_Architecture_and_Capabilities
 
Enabling a Real-Time, Agile, Event-Driven Enterprise
Enabling a Real-Time, Agile, Event-Driven EnterpriseEnabling a Real-Time, Agile, Event-Driven Enterprise
Enabling a Real-Time, Agile, Event-Driven Enterprise
 
Motadata brochure
Motadata brochureMotadata brochure
Motadata brochure
 
DevOps in IoT
DevOps in IoTDevOps in IoT
DevOps in IoT
 
Big Data Berlin v8.0 Stream Processing with Apache Apex
Big Data Berlin v8.0 Stream Processing with Apache Apex Big Data Berlin v8.0 Stream Processing with Apache Apex
Big Data Berlin v8.0 Stream Processing with Apache Apex
 
Thomas Weise, Apache Apex PMC Member and Architect/Co-Founder, DataTorrent - ...
Thomas Weise, Apache Apex PMC Member and Architect/Co-Founder, DataTorrent - ...Thomas Weise, Apache Apex PMC Member and Architect/Co-Founder, DataTorrent - ...
Thomas Weise, Apache Apex PMC Member and Architect/Co-Founder, DataTorrent - ...
 
[WSO2Con EU 2018] The Rise of Streaming SQL
[WSO2Con EU 2018] The Rise of Streaming SQL[WSO2Con EU 2018] The Rise of Streaming SQL
[WSO2Con EU 2018] The Rise of Streaming SQL
 

Mais de Michael Blackstock

Mais de Michael Blackstock (9)

FRED: A Hosted Data Flow Platform for the IoT
FRED: A Hosted Data Flow Platform for the IoTFRED: A Hosted Data Flow Platform for the IoT
FRED: A Hosted Data Flow Platform for the IoT
 
iot-and-smart-cities-lea-blackstock
iot-and-smart-cities-lea-blackstockiot-and-smart-cities-lea-blackstock
iot-and-smart-cities-lea-blackstock
 
IoT Interoperability: a Hub-based Approach
IoT Interoperability: a Hub-based ApproachIoT Interoperability: a Hub-based Approach
IoT Interoperability: a Hub-based Approach
 
Distributed Data Flow for the Web of Things: Distributed Node-RED
Distributed Data Flow for the Web of Things: Distributed Node-REDDistributed Data Flow for the Web of Things: Distributed Node-RED
Distributed Data Flow for the Web of Things: Distributed Node-RED
 
WoT 2013 Thingbroker
WoT 2013 ThingbrokerWoT 2013 Thingbroker
WoT 2013 Thingbroker
 
WoT 2013 Interop
WoT 2013 InteropWoT 2013 Interop
WoT 2013 Interop
 
Wo t 2013-thingbroker
Wo t 2013-thingbrokerWo t 2013-thingbroker
Wo t 2013-thingbroker
 
WoTKit: a Lightweight Toolkit for the Web of Things
WoTKit: a Lightweight Toolkit for the Web of ThingsWoTKit: a Lightweight Toolkit for the Web of Things
WoTKit: a Lightweight Toolkit for the Web of Things
 
Blackstock wo t 2011
Blackstock wo t 2011Blackstock wo t 2011
Blackstock wo t 2011
 

Último

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Último (20)

WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 

CQRS and Event Sourcing for IoT applications

  • 1. Event Sourcing for the IoT Mike Blackstock Sense Tecnic Systems, Inc.
  • 2. Overview • What is the IoT today? • CRUD to Event Sourcing for the IoT • Role of Node-RED in IoT systems • Demonstrate Node-RED and FRED service for IoT app development
  • 3. The IoT Today - Fog Computing • Sense the world • Track assets in a supply chain • Soil moisture levels in fields • Data from factory floor • Actuate to change it • Control lighting • HVAC system control • Control Irrigation • The number of devices far exceeds users…. • Cloud to Fog • data, compute, storage and apps distributed across devices, gateways and cloudhttps://erpinnews.com/fog-computing-vs-edge-computing
  • 4. IoT Application Requirements • Present real world data to end users for decision making • Add intelligence, user control, system control • Variety of protocols, standards & formats • HTTP, MQTT, Websockets, CoAP, OPC, Modbus, Bluetooth, WiFi, LoRaWAN… • Integration with a variety of services • Enterprise systems, alerting systems, virtual ‘sensors’ • “Real time” • Send an alert when a tank level is too high • Turn on irrigation system when moisture too low • Send SMS when taxi is about to arrive • Access to historical data • Time series charts in visualizations • Historical analysis, recognizing patterns, learning • Storage and compute in gateways and devices (fog) • Reduce latency, storage, data rates, and work disconnected
  • 5. Traditional CRUD Applications • IoT apps often start by leveraging traditional frameworks • Model of data where we create records, update them, delete them • Model consists of users, things, information about things • Things and users communicate with the system using a REST API for example. Update Presentation Data Storage Business Logic Data Access Query
  • 6. Challenges • Scale • many things and high data rates • Valuable historical data (events) may be lost • An update from a user or a thing may trigger many operations • checked for alert condition • notification to a user • displayed in a dashboard • processed and sent to an enterprise system • trigger an actuator • count for a subscription • Integrating things & services
  • 7. Adding things • Things could communicate via API • New controllers or presentation servers • Requires real time input and output -- Websockets? • Different protocols required • E.g. how to support MQTT • security and authentication schemes • Historical data • time series data stores. • Business logic to process data may be complex, not easy to scale up. State Storage Business Logic State Data Access Query Users Update API Time Series Storage Time Series Access Presentation Things
  • 8. CQRS: Increase Scalability • Command Query Responsibility Segregation • different logic and data models used to update/write vs. query/read side • Split commands from query model to scale independently. • E.g. mobile app and web pages rendered using query model • User interaction updates command model in write storage • Changes communicated to read storage model either by the database, or communication between command and query processes Presentation Domain Logic Write Storage Generate Views Read Storage Query Generation Commands Queries
  • 9. Adding things • In the IoT, both things and users are updating the command model • How do we scale up and change thing interaction from user interaction independently? • What is the appropriate model for the write storage? • How/where can we make use of time series storage? Domain Logic Write Storage Generate Views Read Storage Query Generation Commands API Presentation UsersThings Time Series Store
  • 10. Event Sourcing • Instance of CQRS where commands validated and processed to create events • Every state change (event) is captured and stored in sequence in an Event Store. • Other processes can subscribe to events. • Characteristics • History – for free • Replay events to regenerate the current state • Or any point in time • Can ‘fix’ state, e.g. By reversing past events. User Presentation Process Commands Event Store Process Events State Store Commands Events Query Generation Published Events Queries
  • 11. Event Sourcing for IoT • Two main sources of events – users and things • Separate thing ‘presentation’ • scaled out independently • often # things > users • Separate thing command processing and generation • Tap event stream for • external systems • Thing actuation • time series storage Actuation User Presentation Process Commands Event Store Process Events State Store Commands Events Query Generation Thing Presentation Process Commands Generate Commands External Systems Sensing Things Events ThingsThings Gateways Things Time Series Store External IoT Systems
  • 12. Summary and Open Questions • Event Sourcing architecture • Can scale “thing presentation” and command processing independently • However CQRS and event sourcing is more complex • Methodologies, toolkits, frameworks available to help (ask Adaptech!) • Remaining Open Questions: • How do we handle the huge variety of protocols, services needed for a complete IoT solution? • How can we quickly get systems up and running? Moving from prototype to production, support testing and simulation? • How can we process data on the edge in gateways and devices for Fog computing?
  • 13. Node-RED and FRED for Event Sourcing • Visual data flow programming – rapid development • Flows, nodes, wires and messages (events) • Huge variety of protocols and services • Can deploy NR flows on edge devices and the cloud (FRED)
  • 14. Why Node-RED? • Almost every “new” thing in the IoT has a different protocol, platform API today. • Complete solutions often require pulling together device protocols, online services • Too much time spent on things like how to access GPIO pins on devices, access serial port, set up HTTP or TCP/UDP endpoints, connect to MQTT broker, OAuth dance on an API, connect to OPC UA server… • Node-RED wraps these issues in “nodes”, and lets developers focus on solution at hand. In our case, getting commands and events in and out of our system.
  • 15. Where does Node-RED fit? • Simple Dashboards • Thing Integration • Device and gateway processing • External System Integration • Designing and Prototyping systems • Testing and simulation User Presentation Process Commands Event Store Process Events State Store Commands Events Query Generation Thing Presentation Process Commands Generate Commands External Systems Things Events ThingsThings Gateways Things State Store External IoT Systems
  • 16. FRED – Cloud-hosted Node-RED Demo
  • 17. WIP: Event Sourcing with Node-RED • Commands & Event processing • Event Store integration • REST API for User Commands & Queries • Get latest state of things • Send control commands • MQTT interface for things • Sensing • Actuation • Dashboard and Alerting • Thing simulation
  • 18. Summary • IoT applications have unique characteristics • Event Sourcing architectures are a natural fit for IoT applications • Node-RED and FRED are useful tools • Thing presentation & integration • service integration • rapid prototyping • Dashboards • Testing & simulation
  • 19. Thank you! Questions? Thanks to Adaptech Solutions for invitation and support! FRED Platform: https://fred.sensetecnic.com (free to try): • Cloud-hosted Node-RED • MQTT service • InfluxDb time series storage Node-RED: https://nodered.org/ mike@sensetecnic.com @mblackstock

Notas do Editor

  1. decentralized computing infrastructure in which data, compute, storage and applications are distributed in the most logical, efficient place between the data source and the cloud
  2. Thinking about how to increase scalability of systems – talking to Adaptech & looking at CQRS and Event Sourcing
  3. Where it doesn’t fit (yet) Not a fully scalable, high performance runtime on its own. Not a mobile app builder Not a multi-user dashboard system Answer to life, the universe and everything…
  4. IoT applications have unique characteristics Variety of protocols Real time, low latency Require historical data storage High data rates, many devices – performance and scale Event Sourcing architecture is a natural fit for IoT applications Everything is an event Scale thing interaction independently Easy to integrate new protocols, functionality Node-RED and FRED are useful tools for IoT application development Data flow programming paradigm – everything is a message/event Create real time dashboards IoT protocol conversion, formatting and service integration Design and Prototyping tool