Académique Documents
Professionnel Documents
Culture Documents
APACHE KAFKA
STREAMING ANALYTICS
OF FAST DATA AND
SERVER PUSH
• Handle influx
• Publish findings instantaneously
• Update UI & notify end user immediately
• Analyze in real time
• Decoupled components
• No data loss when a component is temporarily down
• Scalable with volume of events and of number of clients
THE CASE AT HAND
Tweets on #oow17
#javaone #oraclecode
Show live
tweet feed forAllow users to
conferences like tweets –
and show live Show live
Client list of liked tweet
tweets aggregates
Client per
conference Show a live
list of top 3
Client liked tweets
Client per
conference
THE CODE
https://github.com/lucasjellema/real-time-ui-with-kafka-streams
THE DEO
http://tinyurl.com/kafkaui
EVENTS Consumers
Producers
Robust, Scalable,
History Retention
Containerized/Cloud-
enabled
REQUIREMENTS FOR EVENT CAPABILITY
• Topic Key
Value
• partition Time
• == ByteArray
Broker
• Broker Topic
• replicated
• Producer
• Consumer
• Working together
in Consumer Groups
Consumers
tcp
Producers
tcp
Broker
Topic
THE CASE AT HAND – STEP ONE
Tweets on #oow17
#javaone #oraclecode
Tweets
Topic
Show live
tweet feed for
conferences
Client
Client
Client
Client
THE CASE AT HAND – STEP ONE AND A HALF
Tweets on #oow17
#javaone
#oraclecode
Tweets
Topic
Show live
tweet feed for
conferences
Client
Client
Client
Client
CONFIGURE IFTTT RECIPE
CONFIGURE IFTTT RECIPE
CONFIGURE IFTTT RECIPE
HIGH CODE APPROACH
HIGH CODE (2) – PRODUCE MESSAGE TO KAFKA
THE CASE AT HAND – STEP ONE AND TWO
Tweets on #oow17
#javaone #oraclecode
Tweets
Topic
Show live
tweet feed for
conferences
Client
Client
Client
Client
KAFKA CONSUMER IN NODE
GET EVENTS PUSHED INTO APPLICATION
THE CASE AT HAND
SERVER SENT EVENTS FOR PUSH BACK
Tweets on #oow17
#javaone #oraclecode
Tweets
Topic
Show live
tweet feed for
conferences
Client
Client
Server Sent
Event
Client
Client
SERVER SENT EVENT – SERVER SIDE
SERVER SENT EVENT – CLIENT SIDE
LIVE TWEET STREAM
Server Sent
Event
THE CASE AT HAND
TWEET LIKES – CLIENT TO SERVER TO ALL CLIENTS
Tweets on #oow17
#javaone #oraclecode
Tweets
Topic
Show Allow
live users to
tweet feed fortweets –
like
conferences
and show live
list of liked
Client
tweets
Client
Client SSE
Client
THE CASE AT HAND
WEB SOCKETS – FOR BI DIRECTIONAL PUSH
Tweets on #oow17
#javaone #oraclecode
Tweets
Topic
Show Allow
live users to
tweet feed fortweets –
like
conferences
and show live
list of liked
Client
tweets
Client WebSockets
Client SSE
Client
WEBSOCKETS – SERVER SIDE
WEBSOCKETS – CLIENT SIDE
TWEET LIKES BROADCASTING
WebSockets
WebSockets
THE CASE AT HAND
STREAMING ANALYSIS OF TWEET EVENTS
Tweets on #oow17
#javaone #oraclecode
Tweets
Allow
Show users to
live Topic
tweetlike
feed tweets – live
forShow
and show live
conferences tweet
aggregates
list of liked
tweets per
Client conference
Client WebSockets
Client SSE
Client
THE CASE AT HAND - STREAMING ANALYSIS OF TWEETS
Tweets on #oow17
#javaone #oraclecode
Tweets tweetAnalytics
Allow
Show users to
live Topic Topic
tweetlike
feed tweets – live
forShow
and show live
conferences tweet
aggregates
list of liked Streamingµ
tweets per Tweets
Client conference Aggregation
Client WebSockets
Client SSE
Client
KAFKA STREAMS
• Real Time Event [Stream] Processing integrated into Kafka
• Aggregations & Top-N
• Time Windows
• Continuous Queries
• Latest State (event sourcing)
• Turn Stream (of changes) into Table
(of most recent or current state)
• Part of the state can be quite old
• A Kafka Streams client will have state
in memory
• Always to be recreated from topic partition
log files
• Note: Kafka Streams is relatively new
• Only support for Java clients
KAFKA STREAMS
Topic
Filter
Aggregate
Topic
Join
Map (Xform)
Topic
Publish
EXAMPLE OF KAFKA STREAMS
Topic Set Conference as key
groupBy
Sum/Avg/Top3 by key
TweetMessage (==conference)
Conference Aggregate
Text
and possibly per time window
Author
Hastag Topic
Latest Conference
Join
Details
Round aggregate to
nearest 100 Map (Xform)
As JSON
Publish
Topic: CountTweetsPerConference
KAFKA STREAMS –
RUNNING COUNT TWEETS PER CONFERENCE
STREAMING TWEET ANALYTICS
PUSHED TO CLIENTS
Server Sent
Event
THE CASE AT HAND - STREAMING ANALYSIS
OF TWEET LIKES
Tweets on #oow17
#javaone #oraclecode
Allow
Show users to
live Tweets tweetAnalytics
tweetlike
feed – live
forShow
tweets Topic Topic
and show live
conferences tweet
Show a live
aggregates
list of liked list of top 3
tweets per liked tweets Streamingµ
conferenceper Tweets
Client Aggregation
conference
Client WebSockets
Client SSE
Client
THE CASE AT HAND - STREAMING ANALYSIS
OF TWEET LIKES
Tweets on #oow17
#javaone #oraclecode tweetLike
Topic
Allow
Show users to
live Tweets tweetAnalytics Top3TweetLikes
Topic Topic
tweetlike
feed tweets – live
forShow PerConference
and show live
conferences tweet
Show a live
aggregates
list of liked list of top 3
tweets per liked tweets Streamingµ
conferenceper Tweets
Client Aggregation
conference
Client Likes µ
WebSockets Aggregation
Client SSE
Client
WEBSOCKETS – SERVER SIDE
RUNNING TOP 3 OF
BEST LIKED TWEETS PER CONFERENCE
Server Sent
Event
END TO END FLOW CLOUD ENABLED
Cache
API
EventHub CS
µ Tweets Likes
Tweet Likes
API
Count Top3
µ
UI µ
Client
Chrome
Tweets µ Likes µ
Client Aggregation Aggregation
Firefox
CONCLUSION
• Email: lucas.jellema@amis.nl
• : lucasjellema
• : lucas-jellema
• : www.amis.nl, info@amis.nl
+31 306016000
Edisonbaan 15,
Nieuwegein