SlideShare ist ein Scribd-Unternehmen logo
1 von 106
Downloaden Sie, um offline zu lesen
WHAT IF WE STORED EVENTS
INSTEAD OF STATE?
@JefClaes - jefclaes.be
SCENARIO’S
• The user can put up a card.	

• The user can move the card to the doing section.	

• …
COMMANDS
• Put up a card.	

• Move card to doing section.	

• …
State + Behavior
Traditional systems store current state.
We have no idea what has happened in our system.
Audit logs anyone?
State Audit log
Deposit 500 € 500 €
Deposit 200 € 700 €
Withdraw 300 € 400 €
Deposit 1000 € 1400 €
Withdraw 400 € 1000 €
Withdraw 200 € 800 €
… …
Deposit 500 € Deposited 500 € 500 €
Deposit 200 € Deposited 200 € 700 €
Withdraw 300 € Withdrawn 300 € 400 €
Deposit 300 € Deposited 1000 € 1400 €
Withdraw 400 € Withdrawn 400 € 1000 €
Withdraw 200 € Withdrawn 200 € 800 €
… …
Command - Event - State
Something that happened - past tense.
Store the sequence of events that led up to the
current state, instead of the current state.
Command State
Put up a new card

“Reset Password”	

Card

“Reset Password”

“Todo”
Move card to doing
Card

“Reset Password”

“Doing”
… …
Command Event State
Put up a new card

“Reset Password”	

Card put up

“Reset Password”

“Todo”
Card

“Reset Password”

“Todo”
Move card to doing
Moved card to section

“Doing”
Card

“Reset Password”

“Doing”
… … …
thinkbeforecoding.com
An event store
EventId StreamId Type Payload MetaData
1 card/1	

 CardPutUp { … } { … }
2 card/1
MovedCard	

ToSection
{ … } { … }
3 card/1
MovedCard

ToSection	

{ … }	

 { … }
… … … …
You can’t undo the past.
Append-only.
Forever cacheable.
What about queries?
Model
Writes Reads
Write model
Writes
Write model
Writes
Read model
Reads
Write model
Writes
Read model
Reads
Events
We can build a read model 

from events committed to the write model.
Events Dispatcher Projection Read model
Events Dispatcher Projection Read model
Projection Read model
Events Dispatcher Projection Read model
Projection Read model
Projection Read model
We can build read models 

from events committed to the write model.
More than one way to look at your data.
Behavior

Search

Reporting

Views

…

Complex

Slow

Fragile

What if I mess up my read models?

What if I need to update my read models?

What if I need a new read model?
Temporal queries.
Tell me which day most work gets done.
Monday Tuesday Wednesday …
CardMoved
CardMoved
CardMoved
CardMoved
CardMoved
CardMoved
CardMoved
CardMoved
CardMoved
CardMoved
Not just for read models and queries.
Events Dispatcher Projection Read model
Projection Read model
Projection Read model
Integration
Pub-Sub
Events Dispatcher
Projection
Projection
Projection
Transaction
Events Dispatcher
Projection
Projection
Projection
Events
Projection
Projection
Projection
Events Dispatcher (Queue)
Projection (Queue)
Projection (Queue)
Projection (Queue)
When?
When you can’t afford to lose data.
Business Intelligence

Auditing

Reproducing issues

Challenging/changing business models
Decouple reads from writes
Conceptual purity

Simplicity (no monolith)

Polyglot persistance

Performance

High availability

Integration with other systems

Testing

…
No silver bullet
In conclusion
Event sourcing, for when the 

what and the when are important.
… but really, it’s a lot more than that.
Experiment!
http://neventstore.org/
http://geteventstore.com/
https://groups.google.com/forum/#!forum/dddcqrs
@gregyoung
@abdullin
@randompunter
@jonathan_oliver
@jen20
@yreynhout
@mathiasverraes
@thinkb4coding
@eulerfx
@ziobrando
@tojans
Thank you!	

@JefClaes

http://jefclaes.be

Weitere ähnliche Inhalte

Ähnlich wie What if we stored events instead of state?

Event Sourcing with Kotlin, who needs frameworks!
Event Sourcing with Kotlin, who needs frameworks!Event Sourcing with Kotlin, who needs frameworks!
Event Sourcing with Kotlin, who needs frameworks!
Nico Krijnen
 
Run an Easy to Use Help Desk with Spiceworks
Run an Easy to Use Help Desk with SpiceworksRun an Easy to Use Help Desk with Spiceworks
Run an Easy to Use Help Desk with Spiceworks
Spiceworks
 
Microservices Coordination using Saga
Microservices Coordination using SagaMicroservices Coordination using Saga
Microservices Coordination using Saga
Eran Levy
 
Evan Schultz - Angular Summit - 2016
Evan Schultz - Angular Summit - 2016Evan Schultz - Angular Summit - 2016
Evan Schultz - Angular Summit - 2016
Evan Schultz
 
Symfony & Javascript. Combining the best of two worlds
Symfony & Javascript. Combining the best of two worldsSymfony & Javascript. Combining the best of two worlds
Symfony & Javascript. Combining the best of two worlds
Ignacio Martín
 

Ähnlich wie What if we stored events instead of state? (17)

Event Sourcing with Kotlin, who needs frameworks!
Event Sourcing with Kotlin, who needs frameworks!Event Sourcing with Kotlin, who needs frameworks!
Event Sourcing with Kotlin, who needs frameworks!
 
Spocto a new paradigm
Spocto a new paradigmSpocto a new paradigm
Spocto a new paradigm
 
Run an Easy to Use Help Desk with Spiceworks
Run an Easy to Use Help Desk with SpiceworksRun an Easy to Use Help Desk with Spiceworks
Run an Easy to Use Help Desk with Spiceworks
 
Intelligent Systems for Process Mining
Intelligent Systems for Process MiningIntelligent Systems for Process Mining
Intelligent Systems for Process Mining
 
Dynamic Detection of Malicious Behavior
Dynamic Detection of Malicious BehaviorDynamic Detection of Malicious Behavior
Dynamic Detection of Malicious Behavior
 
​Dynamic Detection of Malicious Behavior
​Dynamic Detection of Malicious Behavior​Dynamic Detection of Malicious Behavior
​Dynamic Detection of Malicious Behavior
 
Event Sourcing & CQRS: Down the rabbit hole
Event Sourcing & CQRS: Down the rabbit holeEvent Sourcing & CQRS: Down the rabbit hole
Event Sourcing & CQRS: Down the rabbit hole
 
Pycon2016- Applying Deep Learning in Information Retrieval System
Pycon2016- Applying Deep Learning in Information Retrieval SystemPycon2016- Applying Deep Learning in Information Retrieval System
Pycon2016- Applying Deep Learning in Information Retrieval System
 
Data oriented design and c++
Data oriented design and c++Data oriented design and c++
Data oriented design and c++
 
Approaches to game AI overview
Approaches to game AI overviewApproaches to game AI overview
Approaches to game AI overview
 
Introduction to Data Mining (Why Mine Data? Commercial Viewpoint)
Introduction to Data Mining (Why Mine Data? Commercial Viewpoint)Introduction to Data Mining (Why Mine Data? Commercial Viewpoint)
Introduction to Data Mining (Why Mine Data? Commercial Viewpoint)
 
Microservices Coordination using Saga
Microservices Coordination using SagaMicroservices Coordination using Saga
Microservices Coordination using Saga
 
Leveraging Large Scale Datasets to Make the Most of In-game Decisions by Dyla...
Leveraging Large Scale Datasets to Make the Most of In-game Decisions by Dyla...Leveraging Large Scale Datasets to Make the Most of In-game Decisions by Dyla...
Leveraging Large Scale Datasets to Make the Most of In-game Decisions by Dyla...
 
Evan Schultz - Angular Summit - 2016
Evan Schultz - Angular Summit - 2016Evan Schultz - Angular Summit - 2016
Evan Schultz - Angular Summit - 2016
 
Quantitative Analysis for Managers Notes.pdf
Quantitative Analysis for Managers Notes.pdfQuantitative Analysis for Managers Notes.pdf
Quantitative Analysis for Managers Notes.pdf
 
Symfony & Javascript. Combining the best of two worlds
Symfony & Javascript. Combining the best of two worldsSymfony & Javascript. Combining the best of two worlds
Symfony & Javascript. Combining the best of two worlds
 
JOSA TechTalks - Word Embedding and Word2Vec Explained
JOSA TechTalks - Word Embedding and Word2Vec ExplainedJOSA TechTalks - Word Embedding and Word2Vec Explained
JOSA TechTalks - Word Embedding and Word2Vec Explained
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

What if we stored events instead of state?