Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Event Streaming Fundamentals

benstopford
September 17, 2019

Event Streaming Fundamentals

Event Streaming Fundamentals

benstopford

September 17, 2019
Tweet

More Decks by benstopford

Other Decks in Technology

Transcript

  1. A new category Relational Database Data warehouse Messaging Complex Event

    Processing NoSQL & Big Data Event Streaming 1970 1980 1990 2000 2010 2020
  2. 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
  3. 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
  4. The log An append-only, time-ordered sequence of immutable records Append

    writes Read cursor Latest events Oldest events
  5. 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
  6. 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
  7. Events: A fact. A real world incident, captured by a

    system. An payment A page view A log line A sensor reading
  8. 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
  9. 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
  10. 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
  11. 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
  12. “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.”
  13. In Event Sourcing events are immutable, stateless and truthful. Events

    retain important information otherwise lost.
  14. 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
  15. 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
  16. Stored as a stream Stored statefully (think DB) 12.42 12.44

    12.49 12.50 12.59 Information lost! Event User Journey
  17. 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
  18. 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
  19. The End State The sequencing of moves is often more

    important than the end state The Game
  20. 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
  21. Another form of “Event Sourcing” - Record what happened -

    Rewind, replay and rederive (View, App, ML, Physics Model etc.)
  22. 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
  23. Billing Shipping Fraud Fraud CUSTOMER ANALYTICS EVENT STORE A Database

    turned Inside Out, Unbundled! Microservice specific materialized views Apps write to the log
  24. 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)
  25. We’ve seen Kafka as an Event Store • Loose coupling

    • Data decoupling • Pluggability • Receiver driven routing • Reload old events
  26. 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
  27. 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
  28. 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