SlideShare una empresa de Scribd logo
1 de 53
Descargar para leer sin conexión
allardbz nklmish
Scaling CQRS in Theory,
Practice and Reality
Allard Buijze
Founder & CTO, AxonIQ
allard@axoniq.io
allardbz
Nakul Mishra
Sr. Engineer & Architect
nklmish@protonmail.com
nklmish
allardbz nklmish
allardbz nklmish
allardbz nklmish
allardbz nklmish
Layered architecture
User Interface
Service Layer
Data Access Layer
DomainModel
allardbz nklmish
Service
Service
Service
allardbz nklmish
‘Normal’ SQL QUERY
22 JOINS 6 SUBQUERIES
allardbz nklmish
Layered architecture
Ponder and deliberate before you make a move. —Sun Tzu
User Interface
Service Layer
Data Access Layer
DomainModel
Method invocation Cache
Worker pools
Web
Cache
Session replication
Distributed 2nd level cache Query Cache
allardbz nklmish
Source: http://www.sabisabi.com/images/DungBeetle-on-dung.JPG
allardbz nklmish
Microservices systems
• Splittingup systemsinto smaller,
simplercomponents
• Agility
• Scalability
allardbz nklmish
CQRS
allardbz nklmish
Command Query Responsibility
Segregation
Command
model
Projections
Client
Events
T: 1 mln / s
Resp: < 10 ms
T: Thr. 20 / s
Resp: < 100 ms
T: 10 mln / s
Resp. < 100 ms
T: 1 / s
Resp. < 10 ms
allardbz nklmish
allardbz nklmish
Are you tall enough?
Source: martinfowler.com/bliki/MicroservicePrerequisites.html
allardbz nklmish
“Noun Driven Design”
allardbz nklmish
“Entity Services”
è
allardbz nklmish
Monoliths
St Breock Downs Monolith - www.cornwalls.co.uk
allardbz nklmish
$
allardbz nklmish
Location transparency
A Component should not be aware, nor make any
assumptions, of the location of Components it
interacts with
A component should neither be aware of nor make any
assumptions about the location of components it interacts with.
Location transparency starts with good API design
(but doesn’tend there)
allardbz nklmish
Microservices Messaging
Commands Events Queries
Route to single handler
Use consistent hashing
Provide result
Distribute to all logical handlers
Consumers express ordering req’s
No results
Route with load balancing
Sometimes scatter/gather
Provide result
"Event" and “Message" is not the same thing
allardbz nklmish
allardbz nklmish
allardbz nklmish
ComponentB
ComponentAWrites / event sourcing
consume event-A
ComponentC
Projection
consume event - A
Read / replay
Built with Axon Framework
publish event - C
BigData Platform
Readshistoricalevents
consumes new events
EventStore
(Percona)
allardbz nklmish
Casumo
• Event storewith >30 billionevents
• Hundreds of millions of events, every day
• Every event is EQUALLY important
“I was thinkingI might win 50 poundsbut when it went all the way
to the jackpotI was shocked.” - Mega Fortune£2,700,000 jackpot
won on the 3rd spin.
allardbz nklmish
allardbz nklmish
allardbz nklmish
Event Store operations
• Append
• Validate‘sequence’
allardbz nklmish
Event Store operations
• Full sequentialread
allardbz nklmish
Event Store operations
• Read aggregate’sevents
allardbz nklmish
Serialized form
• Keep it small
• Use aliases & abbreviations
• Carefully select serializer
allardbz nklmish
Partitioning and archiving
allardbz nklmish
0: Wallet created
€ 7 in wallet @ 3
2: € 1 wagered
3: € 2 wagered
1: € 10 deposited
4: € 1 wagered
5: € 2000 won
6: € 1000 withdrawn
7: € 10 wagered
8: € 1M jackpot won!!
€ 996 in wallet @ 7
Loading aggregates - snapshots
allardbz nklmish
Replays
Event Handler
TRUNCATE TABLE xyz;Projection
allardbz nklmish
Partial replays
Event Handler
TRUNCATE TABLE xyz;
“Reasonable” timeframe
Idempotent event
handling
Perform selective,
ad-hoc, replays
Projection
allardbz nklmish
allardbz nklmish
Exchange
Queue
Queue
Event Store
allardbz nklmish
Exchange
Queue
Queue
Event Store
Queue
allardbz nklmish
allardbz nklmish
Evolutionary microservices
Commands Events Queries
allardbz nklmish
allardbz nklmish
allardbz nklmish
allardbz nklmish
Unmanageable mess
Bet Placed
Bet Accepted
Bet Won
Bet Lost
Bet Reverted
As a Wallet
module I want to
know when to
withdraw money
from the wallet
allardbz nklmish
Communication = Contract
allardbz nklmish
Bounded context
Explicitlydefinethe context within which a model applies.Explicitly
set boundaries in terms of team organization,usage within specific
parts of the application, and physical manifestationssuch as code
bases and databaseschemas. Keep the model strictly consistentwithin
these bounds,but don’t be distractedor confused by issues outside.
allardbz nklmish
Within a context, share ‘everything’
allardbz nklmish
Between contexts, share ‘consciously’As a Wallet
module I want to
know when to
withdraw money
from the wallet
Bet Placed
Bet Accepted
Bet Won
Bet Lost
Bet Reverted
Bet placed
à Claim Funds
allardbz nklmish
Lessons learned
allardbz nklmish
allardbz nklmish
allardbz nklmish
allardbz nklmish
allardbz nklmish
Thank you!

Más contenido relacionado

Similar a Scaling CQRS in theory, practice, and reality

London devops logging
London devops loggingLondon devops logging
London devops logging
Tomas Doran
 

Similar a Scaling CQRS in theory, practice, and reality (20)

AWS re:Invent presentation: Unmeltable Infrastructure at Scale by Loggly
AWS re:Invent presentation: Unmeltable Infrastructure at Scale by Loggly AWS re:Invent presentation: Unmeltable Infrastructure at Scale by Loggly
AWS re:Invent presentation: Unmeltable Infrastructure at Scale by Loggly
 
Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...
Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...
Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...
 
London devops logging
London devops loggingLondon devops logging
London devops logging
 
Collecting 600M events/day
Collecting 600M events/dayCollecting 600M events/day
Collecting 600M events/day
 
Getting Buzzed on Buzzwords: Using Cloud & Big Data to Pentest at Scale
Getting Buzzed on Buzzwords: Using Cloud & Big Data to Pentest at ScaleGetting Buzzed on Buzzwords: Using Cloud & Big Data to Pentest at Scale
Getting Buzzed on Buzzwords: Using Cloud & Big Data to Pentest at Scale
 
Solving Visibility and Streaming in The Witcher 3: Wild Hunt with Umbra 3
Solving Visibility and Streaming in The Witcher 3: Wild Hunt with Umbra 3Solving Visibility and Streaming in The Witcher 3: Wild Hunt with Umbra 3
Solving Visibility and Streaming in The Witcher 3: Wild Hunt with Umbra 3
 
MySQL highav Availability
MySQL highav AvailabilityMySQL highav Availability
MySQL highav Availability
 
Distributed Automation(2018) - London Test Automation in Devops Meetup
Distributed Automation(2018) - London Test Automation in Devops MeetupDistributed Automation(2018) - London Test Automation in Devops Meetup
Distributed Automation(2018) - London Test Automation in Devops Meetup
 
Vertically Scaled Design Patters
Vertically Scaled Design PattersVertically Scaled Design Patters
Vertically Scaled Design Patters
 
Half way to clean architecture - Dmytro Voronkevych - Droidcon Berlin
Half way to clean architecture - Dmytro Voronkevych - Droidcon BerlinHalf way to clean architecture - Dmytro Voronkevych - Droidcon Berlin
Half way to clean architecture - Dmytro Voronkevych - Droidcon Berlin
 
Clojure Conj 2014 - Paradigms of core.async - Julian Gamble
Clojure Conj 2014 - Paradigms of core.async - Julian GambleClojure Conj 2014 - Paradigms of core.async - Julian Gamble
Clojure Conj 2014 - Paradigms of core.async - Julian Gamble
 
20120116 - NvMgr
20120116 - NvMgr20120116 - NvMgr
20120116 - NvMgr
 
Linux Integrity Mechanisms - Protecting Container Runtime as an example
Linux Integrity Mechanisms - Protecting Container Runtime as an exampleLinux Integrity Mechanisms - Protecting Container Runtime as an example
Linux Integrity Mechanisms - Protecting Container Runtime as an example
 
Performance & Scalability Improvements in Perforce
Performance & Scalability Improvements in PerforcePerformance & Scalability Improvements in Perforce
Performance & Scalability Improvements in Perforce
 
Concurrency in Python
Concurrency in PythonConcurrency in Python
Concurrency in Python
 
GOD MODE Unlocked: Hardware backdoors in x86 CPUs
GOD MODE Unlocked: Hardware backdoors in x86 CPUsGOD MODE Unlocked: Hardware backdoors in x86 CPUs
GOD MODE Unlocked: Hardware backdoors in x86 CPUs
 
FreeBSD 2014 Flame Graphs
FreeBSD 2014 Flame GraphsFreeBSD 2014 Flame Graphs
FreeBSD 2014 Flame Graphs
 
Deploying the 'League of Legends' Data Pipeline with Chef (ARC205) | AWS re:I...
Deploying the 'League of Legends' Data Pipeline with Chef (ARC205) | AWS re:I...Deploying the 'League of Legends' Data Pipeline with Chef (ARC205) | AWS re:I...
Deploying the 'League of Legends' Data Pipeline with Chef (ARC205) | AWS re:I...
 
Finding an unusual cause of max_user_connections in MySQL
Finding an unusual cause of max_user_connections in MySQLFinding an unusual cause of max_user_connections in MySQL
Finding an unusual cause of max_user_connections in MySQL
 
Cucumber
CucumberCucumber
Cucumber
 

Más de nklmish

Más de nklmish (10)

Demystifying Kafka
Demystifying KafkaDemystifying Kafka
Demystifying Kafka
 
CQRS and EventSourcing with Spring & Axon
CQRS and EventSourcing with Spring & AxonCQRS and EventSourcing with Spring & Axon
CQRS and EventSourcing with Spring & Axon
 
(SPRING)KAFKA - ONE MORE ARSENAL IN A DISTRIBUTED TOOLBOX
(SPRING)KAFKA - ONE MORE ARSENAL IN A DISTRIBUTED TOOLBOX(SPRING)KAFKA - ONE MORE ARSENAL IN A DISTRIBUTED TOOLBOX
(SPRING)KAFKA - ONE MORE ARSENAL IN A DISTRIBUTED TOOLBOX
 
Kotlin boost yourproductivity
Kotlin boost yourproductivityKotlin boost yourproductivity
Kotlin boost yourproductivity
 
Distributed tracing - get a grasp on your production
Distributed tracing - get a grasp on your productionDistributed tracing - get a grasp on your production
Distributed tracing - get a grasp on your production
 
Spock
SpockSpock
Spock
 
Microservice no fluff, the REAL stuff
Microservice no fluff, the REAL stuffMicroservice no fluff, the REAL stuff
Microservice no fluff, the REAL stuff
 
Neo4J
Neo4JNeo4J
Neo4J
 
Mongo - an intermediate introduction
Mongo - an intermediate introductionMongo - an intermediate introduction
Mongo - an intermediate introduction
 
Detailed Introduction To Docker
Detailed Introduction To DockerDetailed Introduction To Docker
Detailed Introduction To Docker
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 

Scaling CQRS in theory, practice, and reality