from event driven to event sourcing
play

From Event Driven to Event Sourcing by Thomas Bgh Fangel & - PowerPoint PPT Presentation

From Event Driven to Event Sourcing by Thomas Bgh Fangel & Emil Krog Ingerslev 1 Who are we? 2.1 Emil Krog Ingerslev @emilingerslev Site reliability engineer & architect @lunarway Works with Thomas on backend of the future


  1. From Event Driven to Event Sourcing by Thomas Bøgh Fangel & Emil Krog Ingerslev 1

  2. Who are we? 2.1

  3. Emil Krog Ingerslev @emilingerslev Site reliability engineer & architect @lunarway Works with Thomas on backend of the future ❤ reliable efficient automated so�ware coffee geek ☕ Talks... a lot 2.2

  4. Thomas Bøgh Fangel @tbfangel Architect @lunarway Works with Emil on the backend of the future Always looking for a better design ❤ to write and talk about what we do Talks... less 2.3

  5. 2.4

  6. 2.5

  7. in numbers 80.000+ 10M+ +75 Users Transcations Microservices 80+ 1.000M+ 3 Employees € Volume K8S clusters 2.6

  8. Platform Evolution 3.1

  9. From monolith... 3.2

  10. 3.3

  11. ... to event driven microservices ... 75+ async messages microservices communication pattern 10+ integrations 50+ to 3rd parties daily deployments 3.4

  12. ... to event sourcing with consistency guarantees 3.5

  13. Identified some problems found desired characteristics how we implemented them 4.1

  14. a fictive overview not showing message queues databases etc... 4.2

  15. 5.1

  16. We built services CRUD like Behavior: Step 1 - do change in DB Step 2 - publish message 5.2

  17. do change in DB Consistency service fails problem event NOT published 5.3

  18. relied on broker Consistency receiver in dark problem publisher in dark 5.4

  19. receiver never gets event zero-or-once delivery Consequence actually zero-or-more! 5.5

  20. services state dri� weird support cases � hours of logs scrolling � synthetic symptom fixes 5.6

  21. Imagine some other characteristics � “Atomic state change and message publication” + “At-least-once delivery” 5.7

  22. Event sourcing as a solution Every event IS the state change = Atomic event generation & state change 5.8

  23. Read stream Got event #1 Guaranteed Publish event #1 event publishing Save cursor #1 continue to #2 crash 5.9

  24. Starting up Read cursor #1 Guaranteed Read stream from > #1 event publishing Got event #2 Publish event #2 Save cursor #2 5.10

  25. Guaranteed atomic state change + event publishing at least once event publishing 5.11

  26. 6.1

  27. 6.2

  28. Bootstrapping replay from Poor Man the old way synthetic events 6.3

  29. manual process Bootstrapping availability of events problems consistency handling load 6.4

  30. � Can we do better? “Events as first class citizens” + “Event streams with possibility of redelivery” = Bootstrap galore 6.5

  31. Event sourcing as a solution "Every event IS the state change" + API on top of event stream = Events as first class citizens with event streams with redelivery 6.6

  32. Event Sourcing Patterns Bootstrap on-demand Integration events on the outside 6.7

  33. Integration Events are a projection of internal events with same characteristics so whats the purpose? � Less coupling Producer ↔ Consumer 6.8

  34. Producer New Consumer ... Gets request from User #1 ... Asks for events for User #1 Finds event stream for User #1 ... Hydrates integration events � ... ... Sends events back Hydrates User #1 view ... ... Responds to request 6.9

  35. 7.1

  36. Service listens for events Receives event #1 Healing event #2 is sent, but is lost problem Receives event #3 State has dri�ed 7.2

  37. Dri�ing state Consumer le� in dark Consequences Support cases Sync logic to fix problems 7.3

  38. Desired characteristics � Heal our broken state Know if events are missing Redelivery of missing events 7.4

  39. "Event streams with possibility of redelivery" Take 2 � "Ordered event streams with possibility of redelivery" 7.5

  40. Revisiting the event sourcing patterns Bootstrapping was about redelivery from scratch Redelivery from any event 7.6

  41. Service listens for events Receives event #1 Moves cursor to #1 Receives event #3 Self healing Request events since #1 Get event #2 Moves cursor to #2 Continue on event #3 7.7

  42. Pitfalls many streams missing events detected when new event arrives lost last event eventually never consistent dri�ing state 7.8

  43. Reconstitution � Like syncing state, but generic Walk over all known event streams Ask upstream service for events since "internal cursor" Either we receive nothing we receive events ✅ up to date ✅ get up to date Problem solved. Thanks event sourcing � 7.9

  44. 8.1

  45. deprecate existing data add new data modify existing data 8.2

  46. 8.3

  47. hard coupling via events no versioning only additive changes coordinated migrations 8.4

  48. events detached from producer events cannot be updated consumers must adapt 8.5

  49. � Evolution as an ordinary, daily thing? "If it hurts, do it more o�en" 8.6

  50. producer owns events ability to map events to new models controlled, step-wise migrations 8.7

  51. Event sourcing as a solution "Ordered, persisted event streams with easy re- delivery" ➕ integration events on the outside versioning of projections walkers for hydration 8.8

  52. about integration events... internal events can be used for multiple integration event streams � move to new integration events through a non-blocking migration 8.9

  53. Consumers Producer add new projection � ... ... extend consumer 1 extend consumer 2 ... � old projection in consumer 2 ... ... � old projection in consumer 1 � old projection ... mutual agreements strict coordination 8.10

  54. saw problems in old architecture characteristics to eliminate problems found solutions in event sourcing 9.1

  55. Things to take into account not an off the shelf product developing a framework is costly introducing a new service design paradigm is hard solid patterns, easy to improve 9.2

  56. A look from above � A pattern emerges Pain � ➡ Normal � Focus on business domain and iterating... over & over 9.3

  57. If It Hurts, Do It More Frequently, and Bring the Pain Forward - Jez Humble 9.4

  58. hurt to validate state � check state all the time � bootstrapping was hurtful � redelivery as a daily pratice � change is cumbersome & hard change as an enjoyable thing � 9.5

  59. We wont lie It's not an easy solution, but these characteristics & guarantees lead to reliable improvable microservices 9.6

  60. questions? � 10.1

  61. thanks � � Thomas Bøgh Fangel @tbfangel Emil Krog Ingerslev @emilingerslev � 10.2

Recommend


More recommend