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
2k
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
160
GraphQL Without Hype
szymanskilukasz
0
290
PHP's Not Dead - PHP7 In Practice
szymanskilukasz
10
43k
Text Retrieval
szymanskilukasz
0
200
OLX pod maską [PL]
szymanskilukasz
2
730
Other Decks in Programming
See All in Programming
Grafana:建立系統全知視角的捷徑
blueswen
0
330
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
1.3k
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
680
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
430
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
0
170
AtCoder Conference 2025
shindannin
0
1.1k
それ、本当に安全? ファイルアップロードで見落としがちなセキュリティリスクと対策
penpeen
7
3.9k
「ブロックテーマでは再現できない」は本当か?
inc2734
0
970
ぼくの開発環境2026
yuzneri
0
210
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
450
dchart: charts from deck markup
ajstarks
3
990
Honoを使ったリモートMCPサーバでAIツールとの連携を加速させる!
tosuri13
1
180
Featured
See All Featured
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
110
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
310
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.7k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
130
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
0
140
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
The Language of Interfaces
destraynor
162
26k
Thoughts on Productivity
jonyablonski
74
5k
Raft: Consensus for Rubyists
vanstee
141
7.3k
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