SlideShare una empresa de Scribd logo
Technical Lead
Patterns for Building Streaming Apps
Mohanadarshan Vivekanandalingam
Goal
● Streaming analytics? Streaming apps?
● The architecture of a streaming engine
● Understanding streaming constructs
● Applying patterns when building streaming apps
● Managing streaming patterns
● Deployment patterns
Why Streaming ?
Real-time
Near
Real-time
Offline
Constant low
milliseconds &
under
Low milliseconds
to
seconds
10s seconds
to
minutes
● A stream is series of events
● Almost all new data is streaming
● Detects conditions quickly
Image Source : https://www.flickr.com/photos/plusbeautumeurs/33307049175
Why Streaming
Apps?
● Identify perishable insights
● Continuous integration
● Orchestration of business
processes
● Embedded execution of
code
● Sense, think, and act in real
time
- Forrester
How to Build a
Streaming App
Use a Streaming Processor
● Stream processor handles
data flow, scalability, and
failure - you have to handle
the rest
● Publish data to a topic
● Write an end-to-end flow to
consume events and processes
Code it Yourself
Use a Streaming SQL-based
Streaming Processor
● Write the queries using
streaming SQL
Patterns
Streaming Apps
● To understand what stream
processing can do!
● Easy to solve common
problems in stream processing
● Where to use what?
● Learn best practices
Why Patterns for Streaming ?
Image Source : https://www.flickr.com/photos/laurawoodillustration/6986871419
1. Streaming data preprocessing
2. Data store integration
3. Streaming data summarization
4. Interactive data search
5. KPI analysis and alerts
6. Event correlation and trend analysis
7. Real-time predictions
Streaming App Patterns
Stream Processor
Core
Streaming Engine
WSO2 Stream
Processor
Events
JMS, Thrift, SMTP, HTTP, MQTT, Kafka
Analytics Fabric
Complex Event
Processing
Incremental Time
Series Aggregation
Machine
Learning
Extension Store
Financialand
BankingAnalytics
RetailAnalytics
LocationAnalytics
OperationalAnalytics
SmartEnergy
Analytics
Custom Analytics
Solutions
...
Solutions
StatusMonitoring
Rule
Mgmt.
Dashboard
● Lightweight, lean, and cloud native
● Easy to learn streaming SQL (Siddhi SQL)
● High performance analytics with just 2 nodes (HA)
● Native support for streaming machine learning
● Long term aggregations without batch analytics
● Highly scalable deployment with exactly-once processing
● Tools for development and monitoring
● Tools for business users to write their own rules
Overview of WSO2 Stream Processor
Stream Processing
With WSO2 Stream Processor
Siddhi Streaming App
- Process events in a streaming manner
- Isolated unit with a set of queries, input and
output streams
- SQL Like Query Language
from Sales#window.time(1 hour)
select region, brand, avg(quantity) as AvgQuantity
group by region, brand
insert into LastHourSales ;
Stream
Processor
Siddhi App
{ Siddhi }
Input Streams Output Streams
Filter Aggregate
JoinTransform
Pattern
Siddhi Extensions
We need a use case!
Use Case
Online Shopping Application
Place Order
Process
Order
Out for Delivery
Process
Payment
BANK
Use Case
• Monitor sales, supply, and delivery
• Optimize sales, supply, and delivery
• Predict demand/sales
• Recommend products when shopping
• Manage processing rules online
• Visualize real-time sales and delivery
Online Shopping Application
1. Streaming Data Pre-processing
• Consume events from multiple sources
• Convert them to streams
• Filter events
• Add defaults to missing fields
• Change event stream structure
Filtering, Add Defaults, and Projection
Filter
Transform
Process
Add
Defaults
Define Stream
@app:name(‘Online-Shopping-Analytics’)
define stream ProductPurchaseStream(userId
string, sessionId string, productId string,
qty double, price double);
Consume Events:
MQTT, HTTP, TCP, Kafka, JMS,
RabitMQ, etc.
Map Events to
Streams:
JSON, XML, Text, Binary, WSO2Event,
KeyValue, etc.
@app:name(‘Online-Shopping-Analytics’)
@source(type = http, …, @map(type = json, …))
define stream ProductPurchaseStream(userId
string, sessionId string, productId string,
qty double, price double);
Writing the Query
@app:name(‘Online-Shopping-Analytics’)
@source(type = http, …, @map(type = json, …))
define stream ProductPurchaseStream
(userId string, sessionId string, productId
string, qty double, price double);
from ProductPurchaseStream
select *
insert into PossibleDiscountProductStream ;
Filter
@app:name(‘Online-Shopping-Analytics’)
@source(type = http, …, @map(type = json, …))
define stream ProductPurchaseStream(userId
string, sessionId string, productId string,
qty double, price double);
from ProductPurchaseStream [qty > 5 and
productId == ‘XYZ’]
select *
insert into PossibleDiscountProductStream ;
Transformation &
Defaults
@app:name(‘Online-Shopping-Analytics’)
@source(type = http, …, @map(type = json, …))
define stream ProductPurchaseStream(userId
string, sessionId string, productId string,
qty double, price double);
from ProductPurchaseStream [qty > 5 and
productId == ‘XYZ]
select userId, sessionId, productId, qty,
price * 1.17 as usdPrice,
‘USD’ as currency
insert into PossibleDiscountProductStream ;
Functions:
Inbuilt, Custom UDF or
Siddhi Extension
@app:name(‘Online-Shopping-Analytics’)
@source(type = http, …, @map(type = json, …))
define stream ProductPurchaseStream(userId
string, sessionId string, productId string,
qty double, price double);
from ProductPurchaseStream [qty > 5 and
productId == ‘XYZ]
select userId, sessionId, productId, qty,
convertToUSD(price) as usdPrice, ‘USD’ as
currency
insert into PossibleDiscountProductStream ;
2. Data Store Integration
● Allows performing operations with the data store while
processing events on the fly
Store, Retrieve, Remove, and Modify
● Provides a REST endpoint to query Data Store
● Query optimizations using Primary and Indexing keys
● Search ● Insert ● Delete ● Update ● Insert/Update
Define Table
(In Memory)
define stream ShoppingCheckoutStream(userId
string, sessionId string, amount double,
currency string );
define table UserPurchases(userId string,
sessionId string, amount double);
Primary Key &
Indexing
define stream ShoppingCheckoutStream(userId
string, sessionId string, amount double,
currency string );
@primaryKey(‘userId’)
@Index(‘sessionId’)
define table UserPurchases(userId string,
sessionId string, amount double);
Table Backed by:
RDBMS, MongoDB, HBase, Cassandra, Solr,
Hazelcast, etc.
define stream ShoppingCheckoutStream(userId
string, sessionId string, amount double,
currency string );
@store(type=‘rdbms’, … )
@primaryKey(‘userId’)
@Index(‘sessionId’)
define table UserTable(userId string,
sessionId string, amount double);
Insert into Table
define stream ShoppingCheckoutStream(userId
string, sessionId string, amount double,
currency string );
@store(type=‘rdbms’, … )
@primaryKey(‘userId’)
@Index(‘sessionId’)
define table UserTable(userId string,
sessionId string, amount double);
from ShoppingCheckoutStream
select userId, sessionId, amount
insert into UserTable;
3. Streaming Data Summarization
● Can perform aggregations over short and long time periods
● Support for aggregations such as:
○ Sum
○ Count
○ Min/Max
○ Avg
○ etc.
Aggregations Over Time Periods
Aggregations Over a
Short Time
define stream ProductPurchaseStream(userId
string, sessionId string, productId string,
qty double, price double);
from ProductPurchaseStream#window.time(1 min)
select productId, sum(qty) totalQty,
currentTimeMillis() as timestamp
group by productId
insert into LastMinPurchaseStream;
Windows Sliding and Batch for Time,
Length, etc.
3. Streaming Data Summarization
Aggregations Over Long Time Periods
• Incremental aggregation for every
– second, minute, hour, day, year
• Support for out-of-order event arrival
• Fast data retrieval from memory and disk
for real time updates
Current Min
Current Hour
Sec
Min
Hour
0 - 1 - 5 ...
- 1
- 2 - 3 - 4 - 64 - 65 ...
- 2
- 124
Aggregations Over a
Long Time
define stream ProductPurchaseStream(userId
string, sessionId string, productId string,
qty double, price double);
define aggregation PurchaseAggregation
from ProductPurchaseStream
select productId, sum(price * qty) as
totalAmount, sum(qty) as noOfItems
group by productId
aggregate every seconds ... years ;
Define Aggregation
4. Interactive Data Search
Search Data Promptly
• Can perform data search on Data
Stores or pre-defined aggregations.
• Supports both REST and Java APIs
Data Retrieval
Query
from PurchaseAggregation
on productId == ‘XYZ’
within 2018-05-01 2018-06-01
per ‘day’
select productId, totalAmount, noOfItems ;
Dashboard for
Business Users
• Generate dashboard and
widgets
• Fine grained permissions
– Dashboard level
– Widget level
– Data level
• Localization support
• Inter widget communication
• Shareable dashboards with
widget state persistence
5. KPI Analysis and Alerts
Generate Alerts Based on KPIs
• Identify KPIs using
– Filter, ifThenElse, having, etc.
• Send alerts using Sinks
Notify with
Event Sinks
define stream ShoppingPaymentStream(userId
string, name string, email string, sessionId
string, totalAmount double, address string,
isSuccess boolean);
@sink(type=‘email’, to=‘{{email}}’
@map(type=‘text’,
@payload(‘‘‘
Hi, {{name}}
Order placed successfully ...’’’))
define stream SuccessfulPaymentStream (userId
string,name string, email string, ...);
from ShoppingPaymentStream [isSuccess == true]
select *
insert into SuccessfulPaymentStream;
6. Event Correlation & Trend Analysis
CEP for Patterns and Sequences
• Identify complex patterns
– Followed by, non-occurrence, etc.
• Identify trends
– Peek, triple bottom, etc.
Pattern
Detect non-occurrence
define stream ShoppingCheckoutStream(userId
string, sessionId string, amount double,
currency string );
define stream ShoppingPaymentStream(userId
string, name string, email string, sessionId
string, totalAmount double, address string,
isSuccess boolean);
from every (e1 = ShoppingCheckoutStream)
-> not ShoppingPaymentStream
[sessionId == e1.sessionId]
for 15 min
select e1.sessionId, e1.totalAmount
insert into PaymentDelayedStream ;
Sequences
Identify Decreasing Trend
define stream LastMinPurchaseStream(productId
string, totalQty double, timestamp long);
partition with
(productId of LastMinPurchaseStream)
Begin
from every e1=LastMinPurchaseStream,
e2=LastMinPurchaseStream
[timestamp - e1.timestamp < 10 and
e1.totalQty > totalQty]*,
e3=LastMinPurchaseStream
[timestamp - e1.timestamp > 10 and
e2[last].totalQty > totalQty]
select e1.productId, e1.totalQty as
initialQty, e3.totalQty as finalQty
insert into ContinousSalesReductionStream ;
end;
7. Real-time Predictions
Using Machine Learning
• Use pre-created machine learning
models and perform predictions.
– PMML, TensorFlow, etc.
• Streaming Machine Learning
– Clustering, Classification,
Regression
– Markov Models, Anomaly
detection, etc.
Image Source : https://www.flickr.com/photos/149823084@N08/27871878168/
Machine Learning
Models for
Prediction
define stream ShoppingCheckoutStream(userId
string, sessionId string, amount double,
currency string );
from ShoppingCheckoutStream#pmml:predict
(“/home/user/ml.model”, userId)
select *
Insert into ShoppingPredictionStream ;
Continuous Learning
& Prediction
define stream ShoppingCheckoutStream(userId
string, sessionId string, amount double,
currency string );
define stream ShoppingPredictionStream(userId
string, predictedAmount double);
from ShoppingCheckoutStream
#streamingml:hoeffdingTreeTrain
(‘Model’, userId, amount);
...
from ShoppingCheckoutStream
#streamingml:hoeffdingTreeClassifier
(‘Model’, userId);
Select *
Insert into ShoppingPredictionStream;
Online Training
Online Prediction
Managing
Streaming Patterns
Business
Rules for Non
Technical
Users
Define your own
business rules from
scratch
Modify templated
complex business
rules using rule
parameters
Developer Studio
for Streaming
Apps
Supports both drag n
drop & source editor
Editor
Debugger
Simulation
Testing
Graphical Query Builder
Deployment
Streaming Apps
• High performance
– Process around 100k
events/sec
– Just 2 nodes
– While most others need 5+
• Zero downtime & event Loss
• Incremental state persistence &
recovery
• Simple deployment with RDBMS
– No Zookeeper, Kafka, etc.
• Multi data center support
Minimum HA with 2 Nodes
Stream Processor
Stream Processor
Event Sources
Dashboard
Notification
Invocation
Data Source
Siddhi App
Siddhi App
Siddhi App
Siddhi App
Siddhi App
Siddhi App
Event
Store
• Exactly-once processing
• Fault tolerance
• Highly scalable
• No back pressure
• Distributed development configurations via annotations
• Pluggable distribution options (YARN, K8, etc.)
Distributed Deployment
Distributed Deployment with Kafka
Data
Base
Event
Source
Event
Sink
Siddhi
App
Siddhi
App
Siddhi
App
Siddhi
App
Siddhi
App
Siddhi
App
Siddhi
App
Siddhi
App
Siddhi
App
Siddhi
App
Kafka Topic
Kafka Topic
Kafka Topic
Kafka
Topic
Kafka
Topic
Monitoring
Streaming Apps
Status Dashboard
• Understand system performance via
– Throughput
– Latency
– CPU, memory utilizations
• Monitor in various scales
– Node level
– Siddhi app level
– Siddhi query level
Monitor Resource Nodes and Siddhi Apps
To Summarize
● Gives you everything you need to build
streaming analytics
○ Manage data streams
○ Powerful Streaming SQL language
○ Dashboards and more
● Can provide 100K+ events per second with two node
HA (most alternatives need 5+ nodes) and can scale
more on top of Kafka
WSO2 Stream Processor
● Why streaming patterns and when to use them
● How WSO2 Stream Processor can be used to build streaming
patterns
● How to develop streaming patterns with WSO2 Stream
Processor
● The business benefit of manageable rules and dashboards
● Patterns to apply for the deployment of streaming apps
Patterns for Streaming Apps
THANK YOU
wso2.com

Más contenido relacionado

Similar a Patterns for Building Streaming Apps

Azure Stream Analytics : Analyse Data in Motion
Azure Stream Analytics  : Analyse Data in MotionAzure Stream Analytics  : Analyse Data in Motion
Azure Stream Analytics : Analyse Data in Motion
Ruhani Arora
 
WSO2Con ASIA 2016: WSO2 Analytics Platform: The One Stop Shop for All Your Da...
WSO2Con ASIA 2016: WSO2 Analytics Platform: The One Stop Shop for All Your Da...WSO2Con ASIA 2016: WSO2 Analytics Platform: The One Stop Shop for All Your Da...
WSO2Con ASIA 2016: WSO2 Analytics Platform: The One Stop Shop for All Your Da...
WSO2
 
Business Analytics Paradigm Change
Business Analytics Paradigm ChangeBusiness Analytics Paradigm Change
Business Analytics Paradigm Change
Dmitry Anoshin
 
Deep.bi - Real-time, Deep Data Analytics Platform For Ecommerce
Deep.bi - Real-time, Deep Data Analytics Platform For EcommerceDeep.bi - Real-time, Deep Data Analytics Platform For Ecommerce
Deep.bi - Real-time, Deep Data Analytics Platform For Ecommerce
Deep.BI
 
[WSO2Con EU 2017] Deriving Insights for Your Digital Business with Analytics
[WSO2Con EU 2017] Deriving Insights for Your Digital Business with Analytics[WSO2Con EU 2017] Deriving Insights for Your Digital Business with Analytics
[WSO2Con EU 2017] Deriving Insights for Your Digital Business with Analytics
WSO2
 
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB
 
1030 track2 komp
1030 track2 komp1030 track2 komp
1030 track2 komp
Rising Media, Inc.
 
Serverless Streaming Data Processing using Amazon Kinesis Analytics
Serverless Streaming Data Processing using Amazon Kinesis AnalyticsServerless Streaming Data Processing using Amazon Kinesis Analytics
Serverless Streaming Data Processing using Amazon Kinesis Analytics
Amazon Web Services
 
WebAction-Sami Abkay
WebAction-Sami AbkayWebAction-Sami Abkay
WebAction-Sami Abkay
Inside Analysis
 
Big Data Analytics in the Cloud with Microsoft Azure
Big Data Analytics in the Cloud with Microsoft AzureBig Data Analytics in the Cloud with Microsoft Azure
Big Data Analytics in the Cloud with Microsoft Azure
Mark Kromer
 
Microsoft Azure Big Data Analytics
Microsoft Azure Big Data AnalyticsMicrosoft Azure Big Data Analytics
Microsoft Azure Big Data Analytics
Mark Kromer
 
Hadoop in the Cloud: Common Architectural Patterns
Hadoop in the Cloud: Common Architectural PatternsHadoop in the Cloud: Common Architectural Patterns
Hadoop in the Cloud: Common Architectural Patterns
DataWorks Summit
 
Implementing Real-Time IoT Stream Processing in Azure
Implementing Real-Time IoT Stream Processing in Azure Implementing Real-Time IoT Stream Processing in Azure
Implementing Real-Time IoT Stream Processing in Azure
Chris Pietschmann (Microsoft MVP)
 
WSO2Con USA 2017: Analytics Patterns for Your Digital Enterprise
WSO2Con USA 2017: Analytics Patterns for Your Digital EnterpriseWSO2Con USA 2017: Analytics Patterns for Your Digital Enterprise
WSO2Con USA 2017: Analytics Patterns for Your Digital Enterprise
WSO2
 
Analytics Patterns for Your Digital Enterprise
Analytics Patterns for Your Digital EnterpriseAnalytics Patterns for Your Digital Enterprise
Analytics Patterns for Your Digital Enterprise
Sriskandarajah Suhothayan
 
KPI definition with Business Activity Monitor 2.0
KPI definition with Business Activity Monitor 2.0KPI definition with Business Activity Monitor 2.0
KPI definition with Business Activity Monitor 2.0
WSO2
 
1120 track2 komp
1120 track2 komp1120 track2 komp
1120 track2 komp
Rising Media, Inc.
 
Introduction to WSO2 Data Analytics Platform
Introduction to  WSO2 Data Analytics PlatformIntroduction to  WSO2 Data Analytics Platform
Introduction to WSO2 Data Analytics Platform
Srinath Perera
 
Monitoring Your Business with WSO2 BAM
Monitoring Your Business with WSO2 BAMMonitoring Your Business with WSO2 BAM
Monitoring Your Business with WSO2 BAM
Anjana Fernando
 
Api Statistics- The Scalable Way
Api Statistics- The Scalable WayApi Statistics- The Scalable Way
Api Statistics- The Scalable Way
WSO2
 

Similar a Patterns for Building Streaming Apps (20)

Azure Stream Analytics : Analyse Data in Motion
Azure Stream Analytics  : Analyse Data in MotionAzure Stream Analytics  : Analyse Data in Motion
Azure Stream Analytics : Analyse Data in Motion
 
WSO2Con ASIA 2016: WSO2 Analytics Platform: The One Stop Shop for All Your Da...
WSO2Con ASIA 2016: WSO2 Analytics Platform: The One Stop Shop for All Your Da...WSO2Con ASIA 2016: WSO2 Analytics Platform: The One Stop Shop for All Your Da...
WSO2Con ASIA 2016: WSO2 Analytics Platform: The One Stop Shop for All Your Da...
 
Business Analytics Paradigm Change
Business Analytics Paradigm ChangeBusiness Analytics Paradigm Change
Business Analytics Paradigm Change
 
Deep.bi - Real-time, Deep Data Analytics Platform For Ecommerce
Deep.bi - Real-time, Deep Data Analytics Platform For EcommerceDeep.bi - Real-time, Deep Data Analytics Platform For Ecommerce
Deep.bi - Real-time, Deep Data Analytics Platform For Ecommerce
 
[WSO2Con EU 2017] Deriving Insights for Your Digital Business with Analytics
[WSO2Con EU 2017] Deriving Insights for Your Digital Business with Analytics[WSO2Con EU 2017] Deriving Insights for Your Digital Business with Analytics
[WSO2Con EU 2017] Deriving Insights for Your Digital Business with Analytics
 
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
 
1030 track2 komp
1030 track2 komp1030 track2 komp
1030 track2 komp
 
Serverless Streaming Data Processing using Amazon Kinesis Analytics
Serverless Streaming Data Processing using Amazon Kinesis AnalyticsServerless Streaming Data Processing using Amazon Kinesis Analytics
Serverless Streaming Data Processing using Amazon Kinesis Analytics
 
WebAction-Sami Abkay
WebAction-Sami AbkayWebAction-Sami Abkay
WebAction-Sami Abkay
 
Big Data Analytics in the Cloud with Microsoft Azure
Big Data Analytics in the Cloud with Microsoft AzureBig Data Analytics in the Cloud with Microsoft Azure
Big Data Analytics in the Cloud with Microsoft Azure
 
Microsoft Azure Big Data Analytics
Microsoft Azure Big Data AnalyticsMicrosoft Azure Big Data Analytics
Microsoft Azure Big Data Analytics
 
Hadoop in the Cloud: Common Architectural Patterns
Hadoop in the Cloud: Common Architectural PatternsHadoop in the Cloud: Common Architectural Patterns
Hadoop in the Cloud: Common Architectural Patterns
 
Implementing Real-Time IoT Stream Processing in Azure
Implementing Real-Time IoT Stream Processing in Azure Implementing Real-Time IoT Stream Processing in Azure
Implementing Real-Time IoT Stream Processing in Azure
 
WSO2Con USA 2017: Analytics Patterns for Your Digital Enterprise
WSO2Con USA 2017: Analytics Patterns for Your Digital EnterpriseWSO2Con USA 2017: Analytics Patterns for Your Digital Enterprise
WSO2Con USA 2017: Analytics Patterns for Your Digital Enterprise
 
Analytics Patterns for Your Digital Enterprise
Analytics Patterns for Your Digital EnterpriseAnalytics Patterns for Your Digital Enterprise
Analytics Patterns for Your Digital Enterprise
 
KPI definition with Business Activity Monitor 2.0
KPI definition with Business Activity Monitor 2.0KPI definition with Business Activity Monitor 2.0
KPI definition with Business Activity Monitor 2.0
 
1120 track2 komp
1120 track2 komp1120 track2 komp
1120 track2 komp
 
Introduction to WSO2 Data Analytics Platform
Introduction to  WSO2 Data Analytics PlatformIntroduction to  WSO2 Data Analytics Platform
Introduction to WSO2 Data Analytics Platform
 
Monitoring Your Business with WSO2 BAM
Monitoring Your Business with WSO2 BAMMonitoring Your Business with WSO2 BAM
Monitoring Your Business with WSO2 BAM
 
Api Statistics- The Scalable Way
Api Statistics- The Scalable WayApi Statistics- The Scalable Way
Api Statistics- The Scalable Way
 

Último

一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
nuttdpt
 
Global Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headedGlobal Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headed
vikram sood
 
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataPredictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Kiwi Creative
 
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
sameer shah
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
aqzctr7x
 
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdfUdemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Fernanda Palhano
 
A presentation that explain the Power BI Licensing
A presentation that explain the Power BI LicensingA presentation that explain the Power BI Licensing
A presentation that explain the Power BI Licensing
AlessioFois2
 
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
taqyea
 
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docxDATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
SaffaIbrahim1
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
bopyb
 
Challenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more importantChallenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more important
Sm321
 
原版一比一弗林德斯大学毕业证(Flinders毕业证书)如何办理
原版一比一弗林德斯大学毕业证(Flinders毕业证书)如何办理原版一比一弗林德斯大学毕业证(Flinders毕业证书)如何办理
原版一比一弗林德斯大学毕业证(Flinders毕业证书)如何办理
a9qfiubqu
 
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
xclpvhuk
 
Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...
Bill641377
 
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
nyfuhyz
 
"Financial Odyssey: Navigating Past Performance Through Diverse Analytical Lens"
"Financial Odyssey: Navigating Past Performance Through Diverse Analytical Lens""Financial Odyssey: Navigating Past Performance Through Diverse Analytical Lens"
"Financial Odyssey: Navigating Past Performance Through Diverse Analytical Lens"
sameer shah
 
一比一原版兰加拉学院毕业证(Langara毕业证书)学历如何办理
一比一原版兰加拉学院毕业证(Langara毕业证书)学历如何办理一比一原版兰加拉学院毕业证(Langara毕业证书)学历如何办理
一比一原版兰加拉学院毕业证(Langara毕业证书)学历如何办理
hyfjgavov
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
manishkhaire30
 
The Ipsos - AI - Monitor 2024 Report.pdf
The  Ipsos - AI - Monitor 2024 Report.pdfThe  Ipsos - AI - Monitor 2024 Report.pdf
The Ipsos - AI - Monitor 2024 Report.pdf
Social Samosa
 
Analysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performanceAnalysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performance
roli9797
 

Último (20)

一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
一比一原版(UCSF文凭证书)旧金山分校毕业证如何办理
 
Global Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headedGlobal Situational Awareness of A.I. and where its headed
Global Situational Awareness of A.I. and where its headed
 
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging DataPredictably Improve Your B2B Tech Company's Performance by Leveraging Data
Predictably Improve Your B2B Tech Company's Performance by Leveraging Data
 
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
STATATHON: Unleashing the Power of Statistics in a 48-Hour Knowledge Extravag...
 
一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理一比一原版(UO毕业证)渥太华大学毕业证如何办理
一比一原版(UO毕业证)渥太华大学毕业证如何办理
 
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdfUdemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
Udemy_2024_Global_Learning_Skills_Trends_Report (1).pdf
 
A presentation that explain the Power BI Licensing
A presentation that explain the Power BI LicensingA presentation that explain the Power BI Licensing
A presentation that explain the Power BI Licensing
 
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
一比一原版(harvard毕业证书)哈佛大学毕业证如何办理
 
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docxDATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
DATA COMMS-NETWORKS YR2 lecture 08 NAT & CLOUD.docx
 
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
一比一原版(GWU,GW文凭证书)乔治·华盛顿大学毕业证如何办理
 
Challenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more importantChallenges of Nation Building-1.pptx with more important
Challenges of Nation Building-1.pptx with more important
 
原版一比一弗林德斯大学毕业证(Flinders毕业证书)如何办理
原版一比一弗林德斯大学毕业证(Flinders毕业证书)如何办理原版一比一弗林德斯大学毕业证(Flinders毕业证书)如何办理
原版一比一弗林德斯大学毕业证(Flinders毕业证书)如何办理
 
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
一比一原版(Unimelb毕业证书)墨尔本大学毕业证如何办理
 
Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...Population Growth in Bataan: The effects of population growth around rural pl...
Population Growth in Bataan: The effects of population growth around rural pl...
 
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
一比一原版(UMN文凭证书)明尼苏达大学毕业证如何办理
 
"Financial Odyssey: Navigating Past Performance Through Diverse Analytical Lens"
"Financial Odyssey: Navigating Past Performance Through Diverse Analytical Lens""Financial Odyssey: Navigating Past Performance Through Diverse Analytical Lens"
"Financial Odyssey: Navigating Past Performance Through Diverse Analytical Lens"
 
一比一原版兰加拉学院毕业证(Langara毕业证书)学历如何办理
一比一原版兰加拉学院毕业证(Langara毕业证书)学历如何办理一比一原版兰加拉学院毕业证(Langara毕业证书)学历如何办理
一比一原版兰加拉学院毕业证(Langara毕业证书)学历如何办理
 
Learn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queriesLearn SQL from basic queries to Advance queries
Learn SQL from basic queries to Advance queries
 
The Ipsos - AI - Monitor 2024 Report.pdf
The  Ipsos - AI - Monitor 2024 Report.pdfThe  Ipsos - AI - Monitor 2024 Report.pdf
The Ipsos - AI - Monitor 2024 Report.pdf
 
Analysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performanceAnalysis insight about a Flyball dog competition team's performance
Analysis insight about a Flyball dog competition team's performance
 

Patterns for Building Streaming Apps

  • 1. Technical Lead Patterns for Building Streaming Apps Mohanadarshan Vivekanandalingam
  • 2. Goal ● Streaming analytics? Streaming apps? ● The architecture of a streaming engine ● Understanding streaming constructs ● Applying patterns when building streaming apps ● Managing streaming patterns ● Deployment patterns
  • 3. Why Streaming ? Real-time Near Real-time Offline Constant low milliseconds & under Low milliseconds to seconds 10s seconds to minutes ● A stream is series of events ● Almost all new data is streaming ● Detects conditions quickly Image Source : https://www.flickr.com/photos/plusbeautumeurs/33307049175
  • 4. Why Streaming Apps? ● Identify perishable insights ● Continuous integration ● Orchestration of business processes ● Embedded execution of code ● Sense, think, and act in real time - Forrester
  • 5. How to Build a Streaming App Use a Streaming Processor ● Stream processor handles data flow, scalability, and failure - you have to handle the rest ● Publish data to a topic ● Write an end-to-end flow to consume events and processes Code it Yourself Use a Streaming SQL-based Streaming Processor ● Write the queries using streaming SQL
  • 7. ● To understand what stream processing can do! ● Easy to solve common problems in stream processing ● Where to use what? ● Learn best practices Why Patterns for Streaming ? Image Source : https://www.flickr.com/photos/laurawoodillustration/6986871419
  • 8. 1. Streaming data preprocessing 2. Data store integration 3. Streaming data summarization 4. Interactive data search 5. KPI analysis and alerts 6. Event correlation and trend analysis 7. Real-time predictions Streaming App Patterns
  • 9. Stream Processor Core Streaming Engine WSO2 Stream Processor Events JMS, Thrift, SMTP, HTTP, MQTT, Kafka Analytics Fabric Complex Event Processing Incremental Time Series Aggregation Machine Learning Extension Store Financialand BankingAnalytics RetailAnalytics LocationAnalytics OperationalAnalytics SmartEnergy Analytics Custom Analytics Solutions ... Solutions StatusMonitoring Rule Mgmt. Dashboard
  • 10. ● Lightweight, lean, and cloud native ● Easy to learn streaming SQL (Siddhi SQL) ● High performance analytics with just 2 nodes (HA) ● Native support for streaming machine learning ● Long term aggregations without batch analytics ● Highly scalable deployment with exactly-once processing ● Tools for development and monitoring ● Tools for business users to write their own rules Overview of WSO2 Stream Processor
  • 11. Stream Processing With WSO2 Stream Processor Siddhi Streaming App - Process events in a streaming manner - Isolated unit with a set of queries, input and output streams - SQL Like Query Language from Sales#window.time(1 hour) select region, brand, avg(quantity) as AvgQuantity group by region, brand insert into LastHourSales ; Stream Processor Siddhi App { Siddhi } Input Streams Output Streams Filter Aggregate JoinTransform Pattern Siddhi Extensions
  • 12. We need a use case!
  • 13. Use Case Online Shopping Application Place Order Process Order Out for Delivery Process Payment BANK
  • 14. Use Case • Monitor sales, supply, and delivery • Optimize sales, supply, and delivery • Predict demand/sales • Recommend products when shopping • Manage processing rules online • Visualize real-time sales and delivery Online Shopping Application
  • 15. 1. Streaming Data Pre-processing • Consume events from multiple sources • Convert them to streams • Filter events • Add defaults to missing fields • Change event stream structure Filtering, Add Defaults, and Projection Filter Transform Process Add Defaults
  • 16. Define Stream @app:name(‘Online-Shopping-Analytics’) define stream ProductPurchaseStream(userId string, sessionId string, productId string, qty double, price double);
  • 17. Consume Events: MQTT, HTTP, TCP, Kafka, JMS, RabitMQ, etc. Map Events to Streams: JSON, XML, Text, Binary, WSO2Event, KeyValue, etc. @app:name(‘Online-Shopping-Analytics’) @source(type = http, …, @map(type = json, …)) define stream ProductPurchaseStream(userId string, sessionId string, productId string, qty double, price double);
  • 18. Writing the Query @app:name(‘Online-Shopping-Analytics’) @source(type = http, …, @map(type = json, …)) define stream ProductPurchaseStream (userId string, sessionId string, productId string, qty double, price double); from ProductPurchaseStream select * insert into PossibleDiscountProductStream ;
  • 19. Filter @app:name(‘Online-Shopping-Analytics’) @source(type = http, …, @map(type = json, …)) define stream ProductPurchaseStream(userId string, sessionId string, productId string, qty double, price double); from ProductPurchaseStream [qty > 5 and productId == ‘XYZ’] select * insert into PossibleDiscountProductStream ;
  • 20. Transformation & Defaults @app:name(‘Online-Shopping-Analytics’) @source(type = http, …, @map(type = json, …)) define stream ProductPurchaseStream(userId string, sessionId string, productId string, qty double, price double); from ProductPurchaseStream [qty > 5 and productId == ‘XYZ] select userId, sessionId, productId, qty, price * 1.17 as usdPrice, ‘USD’ as currency insert into PossibleDiscountProductStream ;
  • 21. Functions: Inbuilt, Custom UDF or Siddhi Extension @app:name(‘Online-Shopping-Analytics’) @source(type = http, …, @map(type = json, …)) define stream ProductPurchaseStream(userId string, sessionId string, productId string, qty double, price double); from ProductPurchaseStream [qty > 5 and productId == ‘XYZ] select userId, sessionId, productId, qty, convertToUSD(price) as usdPrice, ‘USD’ as currency insert into PossibleDiscountProductStream ;
  • 22. 2. Data Store Integration ● Allows performing operations with the data store while processing events on the fly Store, Retrieve, Remove, and Modify ● Provides a REST endpoint to query Data Store ● Query optimizations using Primary and Indexing keys ● Search ● Insert ● Delete ● Update ● Insert/Update
  • 23. Define Table (In Memory) define stream ShoppingCheckoutStream(userId string, sessionId string, amount double, currency string ); define table UserPurchases(userId string, sessionId string, amount double);
  • 24. Primary Key & Indexing define stream ShoppingCheckoutStream(userId string, sessionId string, amount double, currency string ); @primaryKey(‘userId’) @Index(‘sessionId’) define table UserPurchases(userId string, sessionId string, amount double);
  • 25. Table Backed by: RDBMS, MongoDB, HBase, Cassandra, Solr, Hazelcast, etc. define stream ShoppingCheckoutStream(userId string, sessionId string, amount double, currency string ); @store(type=‘rdbms’, … ) @primaryKey(‘userId’) @Index(‘sessionId’) define table UserTable(userId string, sessionId string, amount double);
  • 26. Insert into Table define stream ShoppingCheckoutStream(userId string, sessionId string, amount double, currency string ); @store(type=‘rdbms’, … ) @primaryKey(‘userId’) @Index(‘sessionId’) define table UserTable(userId string, sessionId string, amount double); from ShoppingCheckoutStream select userId, sessionId, amount insert into UserTable;
  • 27. 3. Streaming Data Summarization ● Can perform aggregations over short and long time periods ● Support for aggregations such as: ○ Sum ○ Count ○ Min/Max ○ Avg ○ etc. Aggregations Over Time Periods
  • 28. Aggregations Over a Short Time define stream ProductPurchaseStream(userId string, sessionId string, productId string, qty double, price double); from ProductPurchaseStream#window.time(1 min) select productId, sum(qty) totalQty, currentTimeMillis() as timestamp group by productId insert into LastMinPurchaseStream; Windows Sliding and Batch for Time, Length, etc.
  • 29. 3. Streaming Data Summarization Aggregations Over Long Time Periods • Incremental aggregation for every – second, minute, hour, day, year • Support for out-of-order event arrival • Fast data retrieval from memory and disk for real time updates Current Min Current Hour Sec Min Hour 0 - 1 - 5 ... - 1 - 2 - 3 - 4 - 64 - 65 ... - 2 - 124
  • 30. Aggregations Over a Long Time define stream ProductPurchaseStream(userId string, sessionId string, productId string, qty double, price double); define aggregation PurchaseAggregation from ProductPurchaseStream select productId, sum(price * qty) as totalAmount, sum(qty) as noOfItems group by productId aggregate every seconds ... years ; Define Aggregation
  • 31. 4. Interactive Data Search Search Data Promptly • Can perform data search on Data Stores or pre-defined aggregations. • Supports both REST and Java APIs
  • 32. Data Retrieval Query from PurchaseAggregation on productId == ‘XYZ’ within 2018-05-01 2018-06-01 per ‘day’ select productId, totalAmount, noOfItems ;
  • 33. Dashboard for Business Users • Generate dashboard and widgets • Fine grained permissions – Dashboard level – Widget level – Data level • Localization support • Inter widget communication • Shareable dashboards with widget state persistence
  • 34.
  • 35. 5. KPI Analysis and Alerts Generate Alerts Based on KPIs • Identify KPIs using – Filter, ifThenElse, having, etc. • Send alerts using Sinks
  • 36. Notify with Event Sinks define stream ShoppingPaymentStream(userId string, name string, email string, sessionId string, totalAmount double, address string, isSuccess boolean); @sink(type=‘email’, to=‘{{email}}’ @map(type=‘text’, @payload(‘‘‘ Hi, {{name}} Order placed successfully ...’’’)) define stream SuccessfulPaymentStream (userId string,name string, email string, ...); from ShoppingPaymentStream [isSuccess == true] select * insert into SuccessfulPaymentStream;
  • 37. 6. Event Correlation & Trend Analysis CEP for Patterns and Sequences • Identify complex patterns – Followed by, non-occurrence, etc. • Identify trends – Peek, triple bottom, etc.
  • 38. Pattern Detect non-occurrence define stream ShoppingCheckoutStream(userId string, sessionId string, amount double, currency string ); define stream ShoppingPaymentStream(userId string, name string, email string, sessionId string, totalAmount double, address string, isSuccess boolean); from every (e1 = ShoppingCheckoutStream) -> not ShoppingPaymentStream [sessionId == e1.sessionId] for 15 min select e1.sessionId, e1.totalAmount insert into PaymentDelayedStream ;
  • 39. Sequences Identify Decreasing Trend define stream LastMinPurchaseStream(productId string, totalQty double, timestamp long); partition with (productId of LastMinPurchaseStream) Begin from every e1=LastMinPurchaseStream, e2=LastMinPurchaseStream [timestamp - e1.timestamp < 10 and e1.totalQty > totalQty]*, e3=LastMinPurchaseStream [timestamp - e1.timestamp > 10 and e2[last].totalQty > totalQty] select e1.productId, e1.totalQty as initialQty, e3.totalQty as finalQty insert into ContinousSalesReductionStream ; end;
  • 40. 7. Real-time Predictions Using Machine Learning • Use pre-created machine learning models and perform predictions. – PMML, TensorFlow, etc. • Streaming Machine Learning – Clustering, Classification, Regression – Markov Models, Anomaly detection, etc. Image Source : https://www.flickr.com/photos/149823084@N08/27871878168/
  • 41. Machine Learning Models for Prediction define stream ShoppingCheckoutStream(userId string, sessionId string, amount double, currency string ); from ShoppingCheckoutStream#pmml:predict (“/home/user/ml.model”, userId) select * Insert into ShoppingPredictionStream ;
  • 42. Continuous Learning & Prediction define stream ShoppingCheckoutStream(userId string, sessionId string, amount double, currency string ); define stream ShoppingPredictionStream(userId string, predictedAmount double); from ShoppingCheckoutStream #streamingml:hoeffdingTreeTrain (‘Model’, userId, amount); ... from ShoppingCheckoutStream #streamingml:hoeffdingTreeClassifier (‘Model’, userId); Select * Insert into ShoppingPredictionStream; Online Training Online Prediction
  • 44. Business Rules for Non Technical Users Define your own business rules from scratch Modify templated complex business rules using rule parameters
  • 45. Developer Studio for Streaming Apps Supports both drag n drop & source editor Editor Debugger Simulation Testing
  • 46.
  • 49. • High performance – Process around 100k events/sec – Just 2 nodes – While most others need 5+ • Zero downtime & event Loss • Incremental state persistence & recovery • Simple deployment with RDBMS – No Zookeeper, Kafka, etc. • Multi data center support Minimum HA with 2 Nodes Stream Processor Stream Processor Event Sources Dashboard Notification Invocation Data Source Siddhi App Siddhi App Siddhi App Siddhi App Siddhi App Siddhi App Event Store
  • 50. • Exactly-once processing • Fault tolerance • Highly scalable • No back pressure • Distributed development configurations via annotations • Pluggable distribution options (YARN, K8, etc.) Distributed Deployment
  • 51. Distributed Deployment with Kafka Data Base Event Source Event Sink Siddhi App Siddhi App Siddhi App Siddhi App Siddhi App Siddhi App Siddhi App Siddhi App Siddhi App Siddhi App Kafka Topic Kafka Topic Kafka Topic Kafka Topic Kafka Topic
  • 53. Status Dashboard • Understand system performance via – Throughput – Latency – CPU, memory utilizations • Monitor in various scales – Node level – Siddhi app level – Siddhi query level Monitor Resource Nodes and Siddhi Apps
  • 54.
  • 55.
  • 57. ● Gives you everything you need to build streaming analytics ○ Manage data streams ○ Powerful Streaming SQL language ○ Dashboards and more ● Can provide 100K+ events per second with two node HA (most alternatives need 5+ nodes) and can scale more on top of Kafka WSO2 Stream Processor
  • 58. ● Why streaming patterns and when to use them ● How WSO2 Stream Processor can be used to build streaming patterns ● How to develop streaming patterns with WSO2 Stream Processor ● The business benefit of manageable rules and dashboards ● Patterns to apply for the deployment of streaming apps Patterns for Streaming Apps