Slide 1

Slide 1 text

Event Streaming Fundamentals Ben Stopford Office of the CTO, Confluent

Slide 2

Slide 2 text

A new category Relational Database Data warehouse Messaging Complex Event Processing NoSQL & Big Data Event Streaming 1970 1980 1990 2000 2010 2020

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Apps Apps Apps Apps Search Monitoring Apps Apps Apps Apps Apps Apps Search Monitoring Apps Apps Apps Search NoSQL Apps Apps DWH Hado S T R E A M I N G P L AT F O R M Apps Search NoSQL Apps DWH S T R E A M I N G P L AT F O R M PRODUCER CONSUMER Event Streaming Platform Apps Search NoSQL Apps Apps DWH Hadoop S T R E A M I N G P L AT F O R M Schema Registry

Slide 5

Slide 5 text

Hang on

Slide 6

Slide 6 text

Isn’t this an ESB?

Slide 7

Slide 7 text

Event Storage Kafka stores petabytes of data Stream Processing Real-time processing over streams and tables Scalability Clusters of hundreds of machines. Global. + + + Roots in big data messaging

Slide 8

Slide 8 text

The log An append-only, time-ordered sequence of immutable records Append writes Read cursor Latest events Oldest events

Slide 9

Slide 9 text

The log can be rewound and replayed Read cursor Latest events Oldest events

Slide 10

Slide 10 text

Solves problems seen in traditional messaging systems • Queue depth problem • Add subscribers at near 0 cost • Load balances multiple consumers with strict ordering • Replay (and store) • 1st class distributed system

Slide 11

Slide 11 text

Event Streaming Events are first class citizens (rows in tables are derivative structures) What changes? • The way we think about data • The way we architect (globally) • The way we evolve an organization • The way we program

Slide 12

Slide 12 text

ESB on steroids?

Slide 13

Slide 13 text

KAFKA IPhone App Stability Query ~once a day

Slide 14

Slide 14 text

Serving Layer (Cassandra etc.) IPhone App Stability KAFKA KStreams Data is summarized on the fly Volume

Slide 15

Slide 15 text

ESB on steroids?

Slide 16

Slide 16 text

THE EVENT-FIRST APPROACH The unification of data and communication.

Slide 17

Slide 17 text

Events: A fact. A real world incident, captured by a system. An payment A page view A log line A sensor reading

Slide 18

Slide 18 text

Events come in streams Apps M onitoring Security Apps Apps L A T F O R M Event Stream Order of events is important Apps M onitoring Apps Apps O R M Older Newer

Slide 19

Slide 19 text

Stream Processors Combine, Filter, Buffer & Summarize Event Streams

Slide 20

Slide 20 text

Code can be embedded in the stream processing layer Business Rules Machine Learning

Slide 21

Slide 21 text

Increasing Complexity Apps Monitoring Security Apps Apps S T R E A M I N G P L AT F O R M Apps Monitoring Security Apps Apps DWH Hadoop S T R E A M I N G P L AT F O R M App Apps Search NoSQL Monitoring Security Apps Apps S T R E A M I N G P L AT F O R M Apps Search NoSQL Monitoring Security Apps Apps DWH Hadoop S T R E A M I N G P L AT F O R M App Apps Search NoSQL Monitoring Security Apps Apps S T R E A M I N G P L AT F O R M App Apps Search NoSQL Monitoring Security Apps Apps S T R E A M I N G P L AT F O R M App Apps Search NoSQL Apps Apps S T R E A M I N G P L AT F O R M Apps Search NoSQL Monitoring Security Apps Apps DWH Hadoop S T R E A M I N G P L AT F O R M App Apps Search NoSQL Mon Sec Apps Apps S T R E A M I N G P L AT F O R M Apps Search NoSQL Monitoring Security Apps Apps DWH Hadoop S T R E A M I N G P L AT F O R M App Apps Search NoSQL Apps App S T R E A M I N G P L AT F O R M Apps Search NoSQL Monitoring Security Apps Apps DWH Hadoop S T R E A M I N G P L AT F O R M App Apps Search NoSQL S T R E A M I N Apps Search NoSQL Apps DWH S T R E A M I N G P L AT App Apps Search NoSQL Apps S T R E A M I N G P L AT Apps Search NoSQL Apps Apps DWH Hadoop S T R E A M I N G P L AT F O R M App Apps Search NoSQL S T Apps Search NoSQL DWH S T R E App Apps Apps Search Apps App Apps Apps Apps Search Apps Apps App Apps Apps Search App Kafka Evolution of software systems Monolith Distributed Monolith Microservices Event-Driven Microservices

Slide 22

Slide 22 text

Apps Search NoSQL Mon Se Apps Apps S T R E A M I N G P L AT F O R M Apps Search NoSQL Monitoring Security Apps Apps DWH Hadoop S T R E A M I N G P L AT F O R M App Apps Search NoSQL Monitoring Security Apps Apps S T R E A M I N G P L AT F O R M Apps Search NoSQL Monitoring Security Apps Apps DWH Hadoop S T R E A M I N G P L AT F O R M App Apps Search NoSQL Apps Apps S T R E A M I N G P L AT F O R M Apps Search NoSQL Monitoring Security Apps Apps DWH Hadoop S T R E A M I N G P L AT F O R M App Apps Apps Apps Apps Search Monitoring Apps Apps App Apps Apps Apps Apps Search Monitoring Apps Apps App Apps Apps Apps Apps Search Monitoring Apps Apps App Kafka Where do you start? Back end tasks Event-Driven Microservices Services • Fraud detection • Recommendations • Billing • Settlement • Analytics Microservices Front End

Slide 23

Slide 23 text

Event shift the way we think Monolithic Approach -A database -a variable -a singleton -a RPC Event First Approach - An event - A stream - A “data” flow - A stream processor

Slide 24

Slide 24 text

“Events are facts that evolve and tell a story. A narrative that describes your system’s evolution as a whole; a day in the life of your business, day after day, forever.”

Slide 25

Slide 25 text

Event Sourcing

Slide 26

Slide 26 text

In Event Sourcing events are immutable, stateless and truthful. Events retain important information otherwise lost.

Slide 27

Slide 27 text

Traditional systems use mutable state DB This isn’t wrong, it’s just lossy Apps Search Mon Apps Apps S T R E A M I N G P L A T F O R M

Slide 28

Slide 28 text

Events record the user’s journey Shopping Cart Events 2 Trousers added 1 Jumper added 1 Trousers removed 1 Hat added Checkout Shopping Cart Event User Journey 12.42 12.44 12.49 12.50 12.59

Slide 29

Slide 29 text

Stored as a stream Stored statefully (think DB) 12.42 12.44 12.49 12.50 12.59 Information lost! Event User Journey

Slide 30

Slide 30 text

12.42 12.44 12.49 12.50 12.59 We can derive the current state (but not the other way around) Apps Apps DERIVE Stream Processor

Slide 31

Slide 31 text

Streaming is a form of Event Sourcing The current state is a projection of the recording Familiar Stateful View LOSSY PROJECTION Stream = Exactly what happened

Slide 32

Slide 32 text

Events describe what happened. Sequences of events (streams) describe how it happened

Slide 33

Slide 33 text

The End State The sequencing of moves is often more important than the end state The Game

Slide 34

Slide 34 text

A stock price: observe the game, not just the current state

Slide 35

Slide 35 text

A customer journey: observe everything

Slide 36

Slide 36 text

Formula 1

Slide 37

Slide 37 text

Formula 1: Observe the game, optimize the end state now and in the future End state

Slide 38

Slide 38 text

Formulae 1 – High-Level Architecture • 400 Sensors on car • 70,000 derivative measures • Events streamed back to base • Analyzed in real time • Tire modelling • Racing line • Aerodynamics • Machine Learning and Physics Models. • Replayed later for post race analysis. Race Track HQ e.g. Tire modelling: - Temp - Pressure - Suspension compression Stream Processing

Slide 39

Slide 39 text

Post race analysis

Slide 40

Slide 40 text

ML Source of Truth Retain events, rewind and replay the stream processor

Slide 41

Slide 41 text

Another form of “Event Sourcing” - Record what happened - Rewind, replay and rederive (View, App, ML, Physics Model etc.)

Slide 42

Slide 42 text

New York Times Source of Truth Every article since 1851 https://www.confluent.io/blog/publishing-apache-kafka-new-york-times/ Normalized assets (images, articles, bylines, tags all separate messages) Denormalized into “Content View” Serving Layer

Slide 43

Slide 43 text

Billing Shipping Fraud Fraud CUSTOMER ANALYTICS EVENT STORE A Database turned Inside Out, Unbundled! Microservice specific materialized views Apps write to the log

Slide 44

Slide 44 text

Event Streams Orders Payments Customers Distinct Visits Destination Spark Postgres Lambda Other Kafka Select Organizational Events Stream Processing SELECT * FROM ORDERS O, CUSTOMERS C WHERE O.REGION = ‘EU’ AND C.TYPE = ‘Platinum’ Msgs/Day Customers Stream Processing Spark Lambda Orders History 1w All Event Streaming Platforms make data self service (via events)

Slide 45

Slide 45 text

We’ve seen Kafka as an Event Store • Loose coupling • Data decoupling • Pluggability • Receiver driven routing • Reload old events

Slide 46

Slide 46 text

What about applications?

Slide 47

Slide 47 text

In the Event Driven World KSQL is the Database

Slide 48

Slide 48 text

Event Driven but not Streaming Orders Customers Payments App ETL ETL

Slide 49

Slide 49 text

Orders Payments KStreams Customers Streaming is Event-First, Event-Sourced & Event-Driven Streaming as an API

Slide 50

Slide 50 text

App KSQL Streaming as a “data layer” for an Event Driven App Stateless “Business Logic” in any language Stateful Orders Payments Customers All relevant data available in “enriched, summarized” events

Slide 51

Slide 51 text

Traditional Application Event-Driven Application Application Database KSQL Stateful “Database” FaaS FaaS FaaS FaaS App Streaming Stateless Stateless Stateless App Layer Stream processors acting as the ‘database’ of the event driven world. App

Slide 52

Slide 52 text

Let’s Summarise: - Event Streaming is more than Messaging or ESBs - Events are truthful, the narrative of your business - Event storage leads to self service evolution - Stream Processors become the databases of the event driven world

Slide 53

Slide 53 text

Thank you @benstopford Book: https://www.confluent.io/designing-event-driven-systems