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

Building Event-Driven Services

benstopford
June 13, 2018
62

Building Event-Driven Services

40 min talk covering how to build event streaming applications / microservices.

benstopford

June 13, 2018
Tweet

Transcript

  1. 4 Today’s ecosystems get pretty big 4 • 2.2 trillion

    messages per day (6 Petabytes) • Up to 400 Microservices pre cluster. • 20-200 Brokers per cluster
  2. 5 Today’s ecosystems get pretty big 5 • 1 billion

    messages per day • 20,000 messages per second • 100 teams
  3. 7 KAFKA Serving Layer (Cassandra etc.) Kafka Streams / KSQL

    Streaming Platforms Data is embedded in each engine High Throughput Messaging Clustered Java App
  4. 8 apps_opened app_crashes unstable_apps crashed_per_day opened_per_day (b) Crashes, Per App,

    Per day (a) Apps Opened, Per App, Per day (c) Unstable Applications Streaming Pipeline
  5. 9 KAFKA Serving Layer (Cassandra etc.) Kafka Streams / KSQL

    Streaming Platforms Data is embedded in each engine High Throughput Messaging Clustered Java App
  6. 10 An event log is a simple idea Messages are

    added at the end of the log Old New
  7. 11 Readers have a position all of their own Sally

    is here George is here Fred is here Old New Scan Scan Scan
  8. 16 KAFKA Serving Layer (Cassandra etc.) Kafka Streams / KSQL

    Streaming Platforms Data is embedded in each engine High Throughput Messaging Clustered Java App
  9. 18 CREATE TABLE opened_per_day AS SELECT app_id, count(*) FROM apps_opened

    WINDOW TUMBLING (SIZE 1 DAY) GROUP BY app_id; apps_opened opened_per_day
  10. 19 CREATE TABLE opened_per_day AS SELECT app_id, count(*) FROM apps_opened

    WINDOW TUMBLING (SIZE 1 DAY) GROUP BY app_id; apps_opened opened_per_day
  11. 20 CREATE TABLE opened_per_day AS SELECT app_id, count(*) FROM apps_opened

    WINDOW TUMBLING (SIZE 1 DAY) GROUP BY app_id; apps_opened opened_per_day
  12. 21 CREATE TABLE opened_per_day AS SELECT app_id, count(*) FROM apps_opened

    WINDOW TUMBLING (SIZE 1 DAY) GROUP BY app_id; apps_opened opened_per_day
  13. 22 CREATE TABLE opened_per_day AS SELECT app_id, count(*) FROM apps_opened

    WINDOW TUMBLING (SIZE 1 DAY) GROUP BY app_id; apps_opened opened_per_day
  14. 23 CREATE TABLE opened_per_day AS SELECT app_id, count(*) FROM apps_opened

    WINDOW TUMBLING (SIZE 1 DAY) GROUP BY app_id; apps_opened opened_per_day
  15. 31 Buying an iPad (with REST/RPC) Submit Order shipOrder() getCustomer()

    Orders Service Shipping Service Customer Service Webserver
  16. 32 Events for Notification Only Message Broker (Kafka) Submit Order

    Order Created getCustomer() REST Notification Orders Service Shipping Service Customer Service Webserver KAFKA
  17. 33 Pluggability Submit Order Order Created Orders Service Shipping Service

    Customer Service Webserver KAFKA Repricing getCustomer() REST Notification
  18. 34 Events for Data Locality Customer Updated Submit Order Order

    Created Data is replicated Orders Service Shipping Service Customer Service Webserver KAFKA
  19. 37 Message Broker (Kafka) Submit Order Order Created getCustomer() REST/RPC

    Orders Service Customer Service Webserver KAFKA KStreams Shipping Service Stateless Stream Processing Notification Kafka Steams / KSQL
  20. 38 Message Broker (Kafka) Submit Order Order Created Orders Service

    Customer Service Webserver KAFKA KStreams Shipping Service KTable Customer Updated Stateful Stream Processing Data replication
  21. 39 Message Broker (Kafka) Orders Stream (Buffer) KAFKA KStreams Shipping

    Service Customers (Buffer All) Streams & Tables Join
  22. 41 Streaming is about 1. Joining & Operating on Streams

    2. Joining & Operating on Materialized Tables On Notification Data Replication
  23. 45 KAFKA Order Requested Order Validated Order Received Browser Webserver

    Orders Service Event Collaboration Order Completed CQRS
  24. 47 KAFKA Order Requested Order Validated Order Received Browser Webserver

    Orders Service Make Legacy Datasets Available via the Log Order Completed CQRS Connect Products
  25. 49 KAFKA Order Requested Order Validated Order Received Browser Webserver

    Orders Service State changes to a topic owned by one service Connect Products Schema Registry Order Completed
  26. 50 Orders Service Email Service T1 T2 T3 T4 REST

    Service T5 Local consistency points in the absence of Global Consistency
  27. 51 4. Use Kafka as a Shared Source of Truth

    (Messaging that Remembers)
  28. 52 KAFKA Order Requested Order Validated Order Received Browser Webserver

    Orders Service Shared Source of Truth Connect Products Schema Registry Order Completed Reporting
  29. 53 KAFKA Order Requested Order Validated Order Received Browser Webserver

    Orders Service Product Catalogue stored in 3 places Connect Products Schema Registry Order Completed Reporting Reporting view may be “thinner”
  30. 55

  31. 56 Connect Order Requested Order Validated Order Completed Order Received

    Products Browser Webserver Schema Registry Orders Service Stock Stock Materialize Stock ‘View’ Inside Service KAFKA
  32. 57 Kafka has several features for reducing the need to

    move data on startup - Standby Replicas - Disk Checkpoints - Compacted topics
  33. 59 Connect Order Requested Order Validated Order Completed Order Received

    Products Browser Webserver Schema Registry Orders Service Reserved Stocks Stock Stock Reserved Stocks State stores behave like local databases KAFKA State Store
  34. 61 Connect TRANSACTION Order Requested Order Validated Order Completed Order

    Received Products Browser Webserver Schema Registry Orders Service Reserved Stocks Stock Stock Reserved Stocks Transactions KAFKA
  35. 69 Spectrum of use cases Finer Grained, Collaborative, Connected Courser

    Grained, Non-collaborative, Disconnected Notification Data Replication
  36. 71 • Broadcast events • Retain them in the log

    • Evolve the event-stream with streaming functions • Recasting the event stream into views when you need to query. Event Driven Services