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
CQRS & Event Sourcing in OLX
Search
Łukasz Szymański
May 16, 2016
Programming
7
1.9k
CQRS & Event Sourcing in OLX
Łukasz Szymański
May 16, 2016
Tweet
Share
More Decks by Łukasz Szymański
See All by Łukasz Szymański
Chain reaction of scaling up
szymanskilukasz
1
130
GraphQL Without Hype
szymanskilukasz
0
260
PHP's Not Dead - PHP7 In Practice
szymanskilukasz
10
42k
Text Retrieval
szymanskilukasz
0
180
OLX pod maską [PL]
szymanskilukasz
2
700
Other Decks in Programming
See All in Programming
High-Level Programming Languages in AI Era -Human Thought and Mind-
hayat01sh1da
PRO
0
770
GitHub Copilot and GitHub Codespaces Hands-on
ymd65536
2
150
AIともっと楽するE2Eテスト
myohei
6
2.6k
A full stack side project webapp all in Kotlin (KotlinConf 2025)
dankim
0
120
システム成長を止めない!本番無停止テーブル移行の全貌
sakawe_ee
1
200
“いい感じ“な定量評価を求めて - Four Keysとアウトカムの間の探求 -
nealle
1
10k
Startups on Rails in Past, Present and Future–Irina Nazarova, RailsConf 2025
irinanazarova
0
100
PHPでWebSocketサーバーを実装しよう2025
kubotak
0
280
Claude Code + Container Use と Cursor で作る ローカル並列開発環境のススメ / ccc local dev
kaelaela
9
5k
Python型ヒント完全ガイド 初心者でも分かる、現代的で実践的な使い方
mickey_kubo
1
110
Systèmes distribués, pour le meilleur et pour le pire - BreizhCamp 2025 - Conférence
slecache
0
120
「テストは愚直&&網羅的に書くほどよい」という誤解 / Test Smarter, Not Harder
munetoshi
0
170
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Scaling GitHub
holman
460
140k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
6
300
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
Building a Modern Day E-commerce SEO Strategy
aleyda
42
7.4k
GraphQLとの向き合い方2022年版
quramy
49
14k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
How GitHub (no longer) Works
holman
314
140k
Speed Design
sergeychernyshev
32
1k
A Tale of Four Properties
chriscoyier
160
23k
Gamification - CAS2011
davidbonilla
81
5.4k
Testing 201, or: Great Expectations
jmmastey
43
7.6k
Transcript
CQRS Event Sourcing in OLX
CQRS
you can use a different model to update information than
the model you use to read information http://martinfowler.com/bliki/CQRS.html „
Command Query Responsibility Segregation
Command Query Responsibility Segregation
new AddCredits($userId, $amount); Command
Command new AddCredits($userId, $amount); Query new GetCredits($userId);
Event Sourcing
http://www.martinfowler.com/eaaDev/EventSourcing.html „ ensures that all changes to application state are
stored as a sequence of events
Not just can we query these events, we can also
use the event log to reconstruct past states http://www.martinfowler.com/eaaDev/EventSourcing.html „
Commad Event Model Event Storage Event Bus Command Handler Listeners
Read Storage Read Model Query
Commad Event Model Event Storage Event Bus Command Handler Listeners
Read Storage Read Model Query Critical section - use transaction
Commad Event Model Event Storage Event Bus Command Handler Listeners
Read Storage Read Model Query Critical section - use transaction Treat like temporary cache
That’s all
E-Wallet Credits; Invoices; Refunds
Wallet Credits Bonus Credits Refund Credits EXPIRE: X DAYS EXPIRE:
X DAYS EXPIRE: X DAYS INVOICE: YES/NO INVOICE: YES/NO INVOICE: YES/NO
Wallet Credits Bonus Credits Refund Credits EXPIRE: NEVER EXPIRE: 90
DAYS EXPIRE: 90 DAYS INVOICE: YES INVOICE: NO INVOICE: YES
Opis walleta w Polsce specyfikacja komenty enventy Commands
Add Wallet Credits Add Bonus Credits Add Refund Credits
Sub Wallet Credits Sub Bonus Credits Sub Refund Credits SubCredits
Opis walleta w Polsce specyfikacja komenty enventy Events
Wallet CreditsWasAdded Bonus CreditsWasAdded Refund CreditsWasAdded
Wallet CreditsWasSubtracted Bonus CreditsWasSubtracted Refund CreditsWasSubtracted
specyfikacja komenty enventy 7 commands 6 events
specyfikacja komenty enventy What about other stuff?
Commad Event Model Event Storage Event Bus Command Handler Listeners
Read Storage Read Model Query ?
Broadway komponenty Broadway https://github.com/qandidate-labs/broadway
Auditing log whether commands were successful or not
CommandHandling Provides the interface and a CommandHandler base class for
handling events
Domain domain abstractions of the Broadway framework including the aggregate
root, domain messages and domain events.
EventDispatcher The component provides an event dispatcher interface and a
simple implementation
EventHandling provides interfaces for an event bus and event listeners,
but also an implementation of a simple event bus and an event bus that will record published events
EventSourcing Provides base classes for event sourced aggregate roots and
entities, an event sourced repository implementation and testing helpers.
EventStore implementation based on doctrine/dbal to store events in a
relational database and an in-memory implementation that is useful for using in tests
ReadModel provides storage for your read models, a projector implementation
to create read models from event streams and testing helpers.
Repository Component providing an abstraction of the storage of aggregates.
Serializers provides a simple serializer interface and a serializer implementation
based on "handwritten" serializers
Commad Event Model Event Storage Event Bus Command Handler Listeners
Read Storage Read Model Query Broadway
Adding Wallet Credits
None
None
Credits Query
None
None
Lessons Learned
Small Steps Don’t try to CQRS/EventSource everything
Keep It Simple Avoid names like BonusCreditsWasSubtractedBecauseAdminHitSubtractBonusCr editsInAdminPanelEvent
Event Storming is not that easy as it sounds
It’s not RDBM Remember about analysts
Code changes Events handle changes to data, what about changes
to code?
Synchronize Remember about synchronizing read layer - especially after fail
Commad Event Model Event Storage Event Bus Command Handler Listeners
Read Storage Read Model Query Critical section - use transaction
Performance is not an issue - for this case
Timezone Agnostic Implement your own EventStore if you want timezone
aware records
Our Team
Paid Features
Next challenge Open source Paid Features libraries with Hexagonal Architecture
in mind
Team Lead PHP Dev Junior PHP Dev You ?
Łukasz Szymański Development Team Lead at @szymanskilukasz http://szymanskilukasz.github.io/ https://www.linkedin.com/in/szymanskilukasz https://twitter.com/szymanskilukasz