Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Event Sourcing in practice
Search
Adam Kosiński
April 12, 2013
Programming
0
450
Event Sourcing in practice
Adam Kosiński
April 12, 2013
Tweet
Share
Other Decks in Programming
See All in Programming
CSC307 Lecture 01
javiergs
PRO
0
690
AWS re:Invent 2025参加 直前 Seattle-Tacoma Airport(SEA)におけるハードウェア紛失インシデントLT
tetutetu214
2
120
CSC307 Lecture 10
javiergs
PRO
1
660
AI時代の認知負荷との向き合い方
optfit
0
160
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
690
並行開発のためのコードレビュー
miyukiw
0
260
Claude Codeと2つの巻き戻し戦略 / Two Rewind Strategies with Claude Code
fruitriin
0
130
今から始めるClaude Code超入門
448jp
8
8.9k
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
5
740
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
270
CSC307 Lecture 05
javiergs
PRO
0
500
[KNOTS 2026登壇資料]AIで拡張‧交差する プロダクト開発のプロセス および携わるメンバーの役割
hisatake
0
290
Featured
See All Featured
Chasing Engaging Ingredients in Design
codingconduct
0
110
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
61
52k
Designing Powerful Visuals for Engaging Learning
tmiket
0
240
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
140
Between Models and Reality
mayunak
1
190
Code Review Best Practice
trishagee
74
20k
Visualization
eitanlees
150
17k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
62
50k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
0
1.1k
How Software Deployment tools have changed in the past 20 years
geshan
0
32k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
67
Transcript
History Defines Us... Event Sourcing in practice Adam Kosiński, 4Developers
2013
About what is Event Sourcing? Imagine a bank account: Transaction
Amount Balance after transaction Payment Deposit + $3000 $3000 Bill Payments - $1800 $1200 CC Charge - $900 $300 Speed Fine - $300 $0
Save state approach $0 WTF!? Why no money? Event sourcing
Payment Deposit + $3000 Bill Payments - $1800 CC Charge - $900 Speed Fine - $300 $0 Hmm… need cheaper room Retrieving our data:
Seriously, what is ES? Entity (State 0) Entity (State 1)
Domain Event #1
Entity (State 1) Entity (State n) Domain Event #1 Domain
Event #2 Domain Event #n ...
Domain Event #1 ... Domain Event #2 Domain Event #3
Domain Event #4 Domain Event #5 Domain Event #6 Entity (Version 6) We only need events Persisted!
What is Domain Event • Something important • Something foreseen
in domain model • Something happened in the past
Sample Domain: Room Access Control AC Software Hardware Controlers Access
Control Zone Lock Valid Permission None or invalid Permission
Access Control Model
Demo #0 Initial, save state model
Demo #1 What We need for Event Sourcing: • Domain
Events • Event Store • Event handling methods
What can be used as event store: • SQL Relational
DB (slight overkill) • NoSql (ie. RavenDB) • EventStore by Greg Young • Even simple file storage :)
Event Sourcing pros: • No ambiguity between events and data
model • Complete historical data • No DB maintenance when modyfying • Very fast data update
Event Sourcing Limitations
Performance when events grow • Can be troublesome to replay
incerasing number of events every time • Solution: Serialized, captured state of entity - Snapshot
Snapshot Event #1 Snapshot (Version3) Entity (Version 6) Event #2
Event #3 Event #4 Event #5 Event #6 Event #4 Event #5 Event #6
Demo #2 • Creating and restoring snapshots • Snapshot store
Yet another issue - Queries • How should we filter
queries? • Almost always a good idea: CQRS select * from eventStore.Entities where … (? ? ?)
What's with Command-Query Responsibility Segregation ? User UI DB Query
(non-domain views) Domain Logic Read Side view-only data Lift up domain entities Update domain Entities Command (non-domain parameters)
Why CQRS helps ES User UI Read Store Query (non-domain
views) Domain Logic Read Side view-only data Add Events Command (non-domain parameters) Event Store Synchronization
Demo #3 • How does Read Store look like •
Synchronization – Read Side Update
ES – to do or not to do • Yes
when: – Event Driven Architecture – History data need – Concurency – Scalable, modifiable systems • Maybe no when: – Simple CRUD apps – No events needed – Initial cost too high – Legacy software
What next: • Greg Young blog, Event Store website: –
http://geteventstore.com/blog/ • Udi Dahan – http://www.udidahan.com/ • Project CQRS Journey – http://cqrsjourney.github.io/ • Szymon Pobiega – http://simon-says-architecture.com/
Thanks for watching! meet me at: https://twitter.com/a_kosinski