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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
Fundamentals of Software Engineering In the Age of AI
therealdanvega
1
250
モックわからないマン卒業記 ~振る舞いを起点に見直した、フロントエンドテストにおけるモックの使いどころ~
tasukuwatanabe
2
370
エンジニアの「手元の自動化」を加速するn8n 2026.02.27
symy2co
0
160
Swift ConcurrencyでよりSwiftyに
yuukiw00w
0
270
API Platformを活用したPHPによる本格的なWeb API開発 / api-platform-book-intro
ttskch
1
140
AI時代のソフトウェア開発でも「人が仕様を書く」から始めよう-医療IT現場での実践とこれから
koukimiura
0
150
Cyrius ーLinux非依存にコンテナをネイティブ実行する専用OSー
n4mlz
0
150
野球解説AI Agentを開発してみた - 2026/02/27 LayerX社内LT会資料
shinyorke
PRO
0
310
社内規程RAGの精度を73.3% → 100%に改善した話
oharu121
13
8.1k
Ruby x Terminal
a_matsuda
7
600
Takumiから考えるSecurity_Maturity_Model.pdf
gessy0129
1
140
ベクトル検索のフィルタを用いた機械学習モデルとの統合 / python-meetup-fukuoka-06-vector-attr
monochromegane
2
440
Featured
See All Featured
KATA
mclloyd
PRO
35
15k
Navigating Weather and Climate Data
rabernat
0
140
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
290
Site-Speed That Sticks
csswizardry
13
1.1k
Rails Girls Zürich Keynote
gr2m
96
14k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
180
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
200
Typedesign – Prime Four
hannesfritz
42
3k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
200
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