SlideShare a Scribd company logo
Introduction to CQRS and Event Sourcing
Joe Drumgoole
Director of Developer Advocacy, EMEA
@jdrumgoole
V1.0
What a Terrible Title for a Talk
4
Event Sourcing – not a new idea
5
Our Relational Friends Love It
6
We do It Ourselves
7
Think of a File backup system
Source
Disk
Backup Disk
8
Trivial Backup
Source
Disk
Backup Disk
MyFile.jpg
9
Just Copy The file
Source
Disk
Backup Disk
MyFile.jpg
MyFile.jpg
10
But…
Source
Disk
Backup Disk
MyFile.jpg
MyFile.jpg
What Happens:
• If the source file changes
• The target file changes
• I copy a dir with 1000 files
• Time passes
11
Lets Use a Backup Tool
Source
Disk
Backup Disk
MyFile.jpg
MyFile.jpg
Admin
12
What if We are a SaaS Backup Company?
MyFile.jpg MyFile.jpg
MyFile.jpg
MyFile.jpg
MyFile.jpg
Audit
MyFile.jpg
MyFile.jpg
MyFile.jpg
MyFile.jpg
MyFile.jpg
MyFile.jpg
MyFile.jpg
MyFile.jpg
MyFile.jpg
MyFile.jpg
MyFile.jpg
MyFile.jpg
MyFile.jpg
MyFile.jpg
Audit
13
What real SaaS Backup Companies do
Event 1
MyFile.jpg
Event 2
Event 3
Event 4
Event 5
Event N
MyFile.jpg Start
MyFile.jpg End
14
Where else is this Useful?
• Taxi haling apps
• Putting stuff into and out of a shopping basket
• Retail inventory
• Everywhere where the system actually turns out to be an
eventually consistent model of the world
15
Key Facets of Event Sourcing
• A immutable log file of events
• The current state is the sum of all previous states
• The events represent
• Events are “domain” level
• Events are generated by the “Commands” or “tasks” your system
undertakes
16
How do you Query an Event Sourcing System?
• Generate snapshots of your state
– Each file upload that is completed in a backup
– All the files per hour for each client computer
– All the files per day for each client computer
• But what about:
– “Find me the myfile.jpg that I backed up last year” ?
17
Command Query Responsibility Segregration
• Most data is queried more often than it is written
• Queries can be eventually consistent
• Commands have to be strongly consistent
• Let’s treat commands as first class objects
• Is predated by CQS
• Commands are related to the business domain
18
Split the Responsibilities
Commands
Commands
Commands
Commands
Commands
Commands
Domain Objects
Events
Events
Events
Events
Events
Events
Events
Events
Domain Objects
Commands
Commands
Commands
Commands
Commands
Queries
Query Objects
Query Objects
Domain Data
Snapshot
Snapshot
Snapshot
19
Things To Note
• Your event store gives you consistent state
• Your domain store gives you business level queries
• Domain store will lag the event store
• Event Store gives you state in the past and future
• Its not a systems design pattern so no frameworks
• Use it if it makes sense to you
20
Lambda Architecture
New
Data
Batch Layer
(Master Data Set)
Speed Layer
Serving Layer
Query
Query
Query
Query
Batch View
Batch View
Batch View
Real Time
View
Real Time
View
21
An Example Project : Filemap
• 226,830 files in $HOME, 139.9 GB
22
The Commands
Add File
Detect File
Change
Compute
Checksum
• Scans Filesystem tree
• Does a stat per file
• Pushes the file to a queue
• Write queue to event store
• Detects create, delete,
rename, write
• Captures new stat
information
• Writes to event store
• Adds checksums to files
without them
23
We have a complete Event State
• When a file was created
• When it was modified
• Its checksum
• To Do:
– When a file changes : recompute its checksum
– Other meta data (image analysis, faster checksum)
– Parser for third party storage (Facebook, Google Pictures)
– Server side storage of data (on AWS)
24
What about the Query Side?
• I want a synthesized view of individual files
• Time ordered
• Duplicate or irrelevant events eliminated
• Can use the aggregation framework to generate this data
• The ability to link data across multiple machines
• The ability to link data across multiple services
25
Summary
• Event Sourcing : Capture the state as first class objects
• CQRS : Optimise differently for commands and queries
• Not an architectural design pattern
• MongoDB ideally suited to build both event store and query store
• Use different storage engines depending on use case
• The aggregation framework generates summary data
Introduction to CQRS and Event Sourcing

More Related Content

Viewers also liked

Back to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in DocumentsBack to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in Documents
Joe Drumgoole
 
Simplifying Enterprise Mobility - Powering Mobile Apps from The Cloud
Simplifying Enterprise Mobility - Powering Mobile Apps from The CloudSimplifying Enterprise Mobility - Powering Mobile Apps from The Cloud
Simplifying Enterprise Mobility - Powering Mobile Apps from The Cloud
Joe Drumgoole
 
Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQL
Joe Drumgoole
 
Harness the web and grow your business
Harness the web and grow your businessHarness the web and grow your business
Harness the web and grow your business
Joe Drumgoole
 
Back to Basics Webinar 2 - Your First MongoDB Application
Back to  Basics Webinar 2 - Your First MongoDB ApplicationBack to  Basics Webinar 2 - Your First MongoDB Application
Back to Basics Webinar 2 - Your First MongoDB Application
Joe Drumgoole
 
Event sourcing the best ubiquitous pattern you have never heard off
Event sourcing   the best ubiquitous pattern you have never heard offEvent sourcing   the best ubiquitous pattern you have never heard off
Event sourcing the best ubiquitous pattern you have never heard off
Joe Drumgoole
 
Be A Startup Not a F**kup
Be A Startup Not a F**kupBe A Startup Not a F**kup
Be A Startup Not a F**kup
Joe Drumgoole
 
Back to Basics Webinar 1 - Introduction to NoSQL
Back to Basics Webinar 1 - Introduction to NoSQLBack to Basics Webinar 1 - Introduction to NoSQL
Back to Basics Webinar 1 - Introduction to NoSQL
Joe Drumgoole
 
EuroPython 2016 : A Deep Dive into the Pymongo Driver
EuroPython 2016 : A Deep Dive into the Pymongo DriverEuroPython 2016 : A Deep Dive into the Pymongo Driver
EuroPython 2016 : A Deep Dive into the Pymongo Driver
Joe Drumgoole
 
Mobile monday mhealth
Mobile monday mhealthMobile monday mhealth
Mobile monday mhealthJoe Drumgoole
 
Server discovery and monitoring with MongoDB
Server discovery and monitoring with MongoDBServer discovery and monitoring with MongoDB
Server discovery and monitoring with MongoDB
Joe Drumgoole
 
A Visual Introduction to Event Sourcing and CQRS by Lorenzo Nicora
A Visual Introduction to Event Sourcing and CQRS by Lorenzo NicoraA Visual Introduction to Event Sourcing and CQRS by Lorenzo Nicora
A Visual Introduction to Event Sourcing and CQRS by Lorenzo Nicora
OpenCredo
 
Python Ireland Conference 2016 - Python and MongoDB Workshop
Python Ireland Conference 2016 - Python and MongoDB WorkshopPython Ireland Conference 2016 - Python and MongoDB Workshop
Python Ireland Conference 2016 - Python and MongoDB Workshop
Joe Drumgoole
 
The Future of IT for Accountants
The Future of IT for AccountantsThe Future of IT for Accountants
The Future of IT for Accountants
Joe Drumgoole
 
CQRS & event sourcing in the wild
CQRS & event sourcing in the wildCQRS & event sourcing in the wild
CQRS & event sourcing in the wild
Michiel Rook
 
CQRS + Event Sourcing
CQRS + Event SourcingCQRS + Event Sourcing
CQRS + Event Sourcing
Mike Bild
 
Internet Safety and Chldren
Internet Safety and ChldrenInternet Safety and Chldren
Internet Safety and ChldrenJoe Drumgoole
 
MongoDB World 2016 : Advanced Aggregation
MongoDB World 2016 : Advanced AggregationMongoDB World 2016 : Advanced Aggregation
MongoDB World 2016 : Advanced Aggregation
Joe Drumgoole
 
A year with event sourcing and CQRS
A year with event sourcing and CQRSA year with event sourcing and CQRS
A year with event sourcing and CQRS
Steve Pember
 

Viewers also liked (20)

Back to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in DocumentsBack to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in Documents
 
Simplifying Enterprise Mobility - Powering Mobile Apps from The Cloud
Simplifying Enterprise Mobility - Powering Mobile Apps from The CloudSimplifying Enterprise Mobility - Powering Mobile Apps from The Cloud
Simplifying Enterprise Mobility - Powering Mobile Apps from The Cloud
 
Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQL
 
Harness the web and grow your business
Harness the web and grow your businessHarness the web and grow your business
Harness the web and grow your business
 
Cloudsplit original
Cloudsplit originalCloudsplit original
Cloudsplit original
 
Back to Basics Webinar 2 - Your First MongoDB Application
Back to  Basics Webinar 2 - Your First MongoDB ApplicationBack to  Basics Webinar 2 - Your First MongoDB Application
Back to Basics Webinar 2 - Your First MongoDB Application
 
Event sourcing the best ubiquitous pattern you have never heard off
Event sourcing   the best ubiquitous pattern you have never heard offEvent sourcing   the best ubiquitous pattern you have never heard off
Event sourcing the best ubiquitous pattern you have never heard off
 
Be A Startup Not a F**kup
Be A Startup Not a F**kupBe A Startup Not a F**kup
Be A Startup Not a F**kup
 
Back to Basics Webinar 1 - Introduction to NoSQL
Back to Basics Webinar 1 - Introduction to NoSQLBack to Basics Webinar 1 - Introduction to NoSQL
Back to Basics Webinar 1 - Introduction to NoSQL
 
EuroPython 2016 : A Deep Dive into the Pymongo Driver
EuroPython 2016 : A Deep Dive into the Pymongo DriverEuroPython 2016 : A Deep Dive into the Pymongo Driver
EuroPython 2016 : A Deep Dive into the Pymongo Driver
 
Mobile monday mhealth
Mobile monday mhealthMobile monday mhealth
Mobile monday mhealth
 
Server discovery and monitoring with MongoDB
Server discovery and monitoring with MongoDBServer discovery and monitoring with MongoDB
Server discovery and monitoring with MongoDB
 
A Visual Introduction to Event Sourcing and CQRS by Lorenzo Nicora
A Visual Introduction to Event Sourcing and CQRS by Lorenzo NicoraA Visual Introduction to Event Sourcing and CQRS by Lorenzo Nicora
A Visual Introduction to Event Sourcing and CQRS by Lorenzo Nicora
 
Python Ireland Conference 2016 - Python and MongoDB Workshop
Python Ireland Conference 2016 - Python and MongoDB WorkshopPython Ireland Conference 2016 - Python and MongoDB Workshop
Python Ireland Conference 2016 - Python and MongoDB Workshop
 
The Future of IT for Accountants
The Future of IT for AccountantsThe Future of IT for Accountants
The Future of IT for Accountants
 
CQRS & event sourcing in the wild
CQRS & event sourcing in the wildCQRS & event sourcing in the wild
CQRS & event sourcing in the wild
 
CQRS + Event Sourcing
CQRS + Event SourcingCQRS + Event Sourcing
CQRS + Event Sourcing
 
Internet Safety and Chldren
Internet Safety and ChldrenInternet Safety and Chldren
Internet Safety and Chldren
 
MongoDB World 2016 : Advanced Aggregation
MongoDB World 2016 : Advanced AggregationMongoDB World 2016 : Advanced Aggregation
MongoDB World 2016 : Advanced Aggregation
 
A year with event sourcing and CQRS
A year with event sourcing and CQRSA year with event sourcing and CQRS
A year with event sourcing and CQRS
 

Similar to Introduction to CQRS and Event Sourcing

DevOps, Databases and The Phoenix Project UGF4042 from OOW14
DevOps, Databases and The Phoenix Project UGF4042 from OOW14DevOps, Databases and The Phoenix Project UGF4042 from OOW14
DevOps, Databases and The Phoenix Project UGF4042 from OOW14
Kyle Hailey
 
Data Virtualization: Revolutionizing data cloning
Data Virtualization: Revolutionizing data cloningData Virtualization: Revolutionizing data cloning
Data Virtualization: Revolutionizing data cloning
Kyle Hailey
 
Building, Evaluating, and Optimizing your RAG App for Production
Building, Evaluating, and Optimizing your RAG App for ProductionBuilding, Evaluating, and Optimizing your RAG App for Production
Building, Evaluating, and Optimizing your RAG App for Production
Sri Ambati
 
BGOUG "Agile Data: revolutionizing database cloning'
BGOUG  "Agile Data: revolutionizing database cloning'BGOUG  "Agile Data: revolutionizing database cloning'
BGOUG "Agile Data: revolutionizing database cloning'
Kyle Hailey
 
Version Control meets Database Control
Version Control meets Database ControlVersion Control meets Database Control
Version Control meets Database Control
DBmaestro - Database DevOps
 
Data as a Service
Data as a Service Data as a Service
Data as a Service
Kyle Hailey
 
Denver devops : enabling DevOps with data virtualization
Denver devops : enabling DevOps with data virtualizationDenver devops : enabling DevOps with data virtualization
Denver devops : enabling DevOps with data virtualization
Kyle Hailey
 
Merging and Migrating: Data Portability from the Trenches
Merging and Migrating: Data Portability from the TrenchesMerging and Migrating: Data Portability from the Trenches
Merging and Migrating: Data Portability from the Trenches
Atlassian
 
TYPO3 Event Sourcing
TYPO3 Event SourcingTYPO3 Event Sourcing
TYPO3 Event Sourcing
Oliver Hader
 
Investigate TempDB Like Sherlock Holmes
Investigate TempDB Like Sherlock HolmesInvestigate TempDB Like Sherlock Holmes
Investigate TempDB Like Sherlock Holmes
Richard Douglas
 
The Journey to Data Mesh with Confluent
The Journey to Data Mesh with ConfluentThe Journey to Data Mesh with Confluent
The Journey to Data Mesh with Confluent
confluent
 
Using Perforce Data in Development at Tableau
Using Perforce Data in Development at TableauUsing Perforce Data in Development at Tableau
Using Perforce Data in Development at Tableau
Perforce
 
Integrating Hadoop in Your Existing DW and BI Environment
Integrating Hadoop in Your Existing DW and BI EnvironmentIntegrating Hadoop in Your Existing DW and BI Environment
Integrating Hadoop in Your Existing DW and BI Environment
Cloudera, Inc.
 
How to Get IBM i Security and Operational Insights with Splunk
How to Get IBM i Security and Operational Insights with SplunkHow to Get IBM i Security and Operational Insights with Splunk
How to Get IBM i Security and Operational Insights with Splunk
Precisely
 
Data Virtualization: revolutionizing database cloning
Data Virtualization: revolutionizing database cloningData Virtualization: revolutionizing database cloning
Data Virtualization: revolutionizing database cloningKyle Hailey
 
Lessons Learned Replatforming A Large Machine Learning Application To Apache ...
Lessons Learned Replatforming A Large Machine Learning Application To Apache ...Lessons Learned Replatforming A Large Machine Learning Application To Apache ...
Lessons Learned Replatforming A Large Machine Learning Application To Apache ...
Databricks
 
All course slides.pdf
All course slides.pdfAll course slides.pdf
All course slides.pdf
ssuser98bffa1
 
Capacity - Ransomware - Protection - Three Windows File Server Upgrades to Avoid
Capacity - Ransomware - Protection - Three Windows File Server Upgrades to AvoidCapacity - Ransomware - Protection - Three Windows File Server Upgrades to Avoid
Capacity - Ransomware - Protection - Three Windows File Server Upgrades to Avoid
Storage Switzerland
 
Data Replication Options in AWS (ARC302) | AWS re:Invent 2013
Data Replication Options in AWS (ARC302) | AWS re:Invent 2013Data Replication Options in AWS (ARC302) | AWS re:Invent 2013
Data Replication Options in AWS (ARC302) | AWS re:Invent 2013
Amazon Web Services
 
10 Reasons Snowflake Is Great for Analytics
10 Reasons Snowflake Is Great for Analytics10 Reasons Snowflake Is Great for Analytics
10 Reasons Snowflake Is Great for Analytics
Senturus
 

Similar to Introduction to CQRS and Event Sourcing (20)

DevOps, Databases and The Phoenix Project UGF4042 from OOW14
DevOps, Databases and The Phoenix Project UGF4042 from OOW14DevOps, Databases and The Phoenix Project UGF4042 from OOW14
DevOps, Databases and The Phoenix Project UGF4042 from OOW14
 
Data Virtualization: Revolutionizing data cloning
Data Virtualization: Revolutionizing data cloningData Virtualization: Revolutionizing data cloning
Data Virtualization: Revolutionizing data cloning
 
Building, Evaluating, and Optimizing your RAG App for Production
Building, Evaluating, and Optimizing your RAG App for ProductionBuilding, Evaluating, and Optimizing your RAG App for Production
Building, Evaluating, and Optimizing your RAG App for Production
 
BGOUG "Agile Data: revolutionizing database cloning'
BGOUG  "Agile Data: revolutionizing database cloning'BGOUG  "Agile Data: revolutionizing database cloning'
BGOUG "Agile Data: revolutionizing database cloning'
 
Version Control meets Database Control
Version Control meets Database ControlVersion Control meets Database Control
Version Control meets Database Control
 
Data as a Service
Data as a Service Data as a Service
Data as a Service
 
Denver devops : enabling DevOps with data virtualization
Denver devops : enabling DevOps with data virtualizationDenver devops : enabling DevOps with data virtualization
Denver devops : enabling DevOps with data virtualization
 
Merging and Migrating: Data Portability from the Trenches
Merging and Migrating: Data Portability from the TrenchesMerging and Migrating: Data Portability from the Trenches
Merging and Migrating: Data Portability from the Trenches
 
TYPO3 Event Sourcing
TYPO3 Event SourcingTYPO3 Event Sourcing
TYPO3 Event Sourcing
 
Investigate TempDB Like Sherlock Holmes
Investigate TempDB Like Sherlock HolmesInvestigate TempDB Like Sherlock Holmes
Investigate TempDB Like Sherlock Holmes
 
The Journey to Data Mesh with Confluent
The Journey to Data Mesh with ConfluentThe Journey to Data Mesh with Confluent
The Journey to Data Mesh with Confluent
 
Using Perforce Data in Development at Tableau
Using Perforce Data in Development at TableauUsing Perforce Data in Development at Tableau
Using Perforce Data in Development at Tableau
 
Integrating Hadoop in Your Existing DW and BI Environment
Integrating Hadoop in Your Existing DW and BI EnvironmentIntegrating Hadoop in Your Existing DW and BI Environment
Integrating Hadoop in Your Existing DW and BI Environment
 
How to Get IBM i Security and Operational Insights with Splunk
How to Get IBM i Security and Operational Insights with SplunkHow to Get IBM i Security and Operational Insights with Splunk
How to Get IBM i Security and Operational Insights with Splunk
 
Data Virtualization: revolutionizing database cloning
Data Virtualization: revolutionizing database cloningData Virtualization: revolutionizing database cloning
Data Virtualization: revolutionizing database cloning
 
Lessons Learned Replatforming A Large Machine Learning Application To Apache ...
Lessons Learned Replatforming A Large Machine Learning Application To Apache ...Lessons Learned Replatforming A Large Machine Learning Application To Apache ...
Lessons Learned Replatforming A Large Machine Learning Application To Apache ...
 
All course slides.pdf
All course slides.pdfAll course slides.pdf
All course slides.pdf
 
Capacity - Ransomware - Protection - Three Windows File Server Upgrades to Avoid
Capacity - Ransomware - Protection - Three Windows File Server Upgrades to AvoidCapacity - Ransomware - Protection - Three Windows File Server Upgrades to Avoid
Capacity - Ransomware - Protection - Three Windows File Server Upgrades to Avoid
 
Data Replication Options in AWS (ARC302) | AWS re:Invent 2013
Data Replication Options in AWS (ARC302) | AWS re:Invent 2013Data Replication Options in AWS (ARC302) | AWS re:Invent 2013
Data Replication Options in AWS (ARC302) | AWS re:Invent 2013
 
10 Reasons Snowflake Is Great for Analytics
10 Reasons Snowflake Is Great for Analytics10 Reasons Snowflake Is Great for Analytics
10 Reasons Snowflake Is Great for Analytics
 

More from Joe Drumgoole

MongoDB Schema Design
MongoDB Schema DesignMongoDB Schema Design
MongoDB Schema Design
Joe Drumgoole
 
The Rise of Microservices
The Rise of MicroservicesThe Rise of Microservices
The Rise of Microservices
Joe Drumgoole
 
Back to Basics 2017 - Your First MongoDB Application
Back to Basics 2017 - Your First MongoDB ApplicationBack to Basics 2017 - Your First MongoDB Application
Back to Basics 2017 - Your First MongoDB Application
Joe Drumgoole
 
Back to Basics 2017 - Introduction to NoSQL
Back to Basics 2017 - Introduction to NoSQLBack to Basics 2017 - Introduction to NoSQL
Back to Basics 2017 - Introduction to NoSQL
Joe Drumgoole
 
How to run a company for 2k a year
How to run a company for 2k a yearHow to run a company for 2k a year
How to run a company for 2k a yearJoe Drumgoole
 
How to Run a Company for $2000 a Year
How to Run a Company for $2000 a YearHow to Run a Company for $2000 a Year
How to Run a Company for $2000 a Year
Joe Drumgoole
 
Smart Phones - Smart Platforms
Smart Phones - Smart PlatformsSmart Phones - Smart Platforms
Smart Phones - Smart Platforms
Joe Drumgoole
 
Cloud Computing - A Gentle Introduction
Cloud Computing - A Gentle IntroductionCloud Computing - A Gentle Introduction
Cloud Computing - A Gentle Introduction
Joe Drumgoole
 
The costs of cloud computing
The costs of cloud computingThe costs of cloud computing
The costs of cloud computing
Joe Drumgoole
 
A cheap date with cloud computing
A cheap date with cloud computingA cheap date with cloud computing
A cheap date with cloud computing
Joe Drumgoole
 
Software warstories mba-club
Software warstories mba-clubSoftware warstories mba-club
Software warstories mba-clubJoe Drumgoole
 
Agile development using SCRUM
Agile development using SCRUMAgile development using SCRUM
Agile development using SCRUM
Joe Drumgoole
 

More from Joe Drumgoole (12)

MongoDB Schema Design
MongoDB Schema DesignMongoDB Schema Design
MongoDB Schema Design
 
The Rise of Microservices
The Rise of MicroservicesThe Rise of Microservices
The Rise of Microservices
 
Back to Basics 2017 - Your First MongoDB Application
Back to Basics 2017 - Your First MongoDB ApplicationBack to Basics 2017 - Your First MongoDB Application
Back to Basics 2017 - Your First MongoDB Application
 
Back to Basics 2017 - Introduction to NoSQL
Back to Basics 2017 - Introduction to NoSQLBack to Basics 2017 - Introduction to NoSQL
Back to Basics 2017 - Introduction to NoSQL
 
How to run a company for 2k a year
How to run a company for 2k a yearHow to run a company for 2k a year
How to run a company for 2k a year
 
How to Run a Company for $2000 a Year
How to Run a Company for $2000 a YearHow to Run a Company for $2000 a Year
How to Run a Company for $2000 a Year
 
Smart Phones - Smart Platforms
Smart Phones - Smart PlatformsSmart Phones - Smart Platforms
Smart Phones - Smart Platforms
 
Cloud Computing - A Gentle Introduction
Cloud Computing - A Gentle IntroductionCloud Computing - A Gentle Introduction
Cloud Computing - A Gentle Introduction
 
The costs of cloud computing
The costs of cloud computingThe costs of cloud computing
The costs of cloud computing
 
A cheap date with cloud computing
A cheap date with cloud computingA cheap date with cloud computing
A cheap date with cloud computing
 
Software warstories mba-club
Software warstories mba-clubSoftware warstories mba-club
Software warstories mba-club
 
Agile development using SCRUM
Agile development using SCRUMAgile development using SCRUM
Agile development using SCRUM
 

Recently uploaded

Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 

Recently uploaded (20)

Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 

Introduction to CQRS and Event Sourcing

  • 1.
  • 2. Introduction to CQRS and Event Sourcing Joe Drumgoole Director of Developer Advocacy, EMEA @jdrumgoole V1.0
  • 3. What a Terrible Title for a Talk
  • 4. 4 Event Sourcing – not a new idea
  • 6. 6 We do It Ourselves
  • 7. 7 Think of a File backup system Source Disk Backup Disk
  • 9. 9 Just Copy The file Source Disk Backup Disk MyFile.jpg MyFile.jpg
  • 10. 10 But… Source Disk Backup Disk MyFile.jpg MyFile.jpg What Happens: • If the source file changes • The target file changes • I copy a dir with 1000 files • Time passes
  • 11. 11 Lets Use a Backup Tool Source Disk Backup Disk MyFile.jpg MyFile.jpg Admin
  • 12. 12 What if We are a SaaS Backup Company? MyFile.jpg MyFile.jpg MyFile.jpg MyFile.jpg MyFile.jpg Audit MyFile.jpg MyFile.jpg MyFile.jpg MyFile.jpg MyFile.jpg MyFile.jpg MyFile.jpg MyFile.jpg MyFile.jpg MyFile.jpg MyFile.jpg MyFile.jpg MyFile.jpg MyFile.jpg Audit
  • 13. 13 What real SaaS Backup Companies do Event 1 MyFile.jpg Event 2 Event 3 Event 4 Event 5 Event N MyFile.jpg Start MyFile.jpg End
  • 14. 14 Where else is this Useful? • Taxi haling apps • Putting stuff into and out of a shopping basket • Retail inventory • Everywhere where the system actually turns out to be an eventually consistent model of the world
  • 15. 15 Key Facets of Event Sourcing • A immutable log file of events • The current state is the sum of all previous states • The events represent • Events are “domain” level • Events are generated by the “Commands” or “tasks” your system undertakes
  • 16. 16 How do you Query an Event Sourcing System? • Generate snapshots of your state – Each file upload that is completed in a backup – All the files per hour for each client computer – All the files per day for each client computer • But what about: – “Find me the myfile.jpg that I backed up last year” ?
  • 17. 17 Command Query Responsibility Segregration • Most data is queried more often than it is written • Queries can be eventually consistent • Commands have to be strongly consistent • Let’s treat commands as first class objects • Is predated by CQS • Commands are related to the business domain
  • 18. 18 Split the Responsibilities Commands Commands Commands Commands Commands Commands Domain Objects Events Events Events Events Events Events Events Events Domain Objects Commands Commands Commands Commands Commands Queries Query Objects Query Objects Domain Data Snapshot Snapshot Snapshot
  • 19. 19 Things To Note • Your event store gives you consistent state • Your domain store gives you business level queries • Domain store will lag the event store • Event Store gives you state in the past and future • Its not a systems design pattern so no frameworks • Use it if it makes sense to you
  • 20. 20 Lambda Architecture New Data Batch Layer (Master Data Set) Speed Layer Serving Layer Query Query Query Query Batch View Batch View Batch View Real Time View Real Time View
  • 21. 21 An Example Project : Filemap • 226,830 files in $HOME, 139.9 GB
  • 22. 22 The Commands Add File Detect File Change Compute Checksum • Scans Filesystem tree • Does a stat per file • Pushes the file to a queue • Write queue to event store • Detects create, delete, rename, write • Captures new stat information • Writes to event store • Adds checksums to files without them
  • 23. 23 We have a complete Event State • When a file was created • When it was modified • Its checksum • To Do: – When a file changes : recompute its checksum – Other meta data (image analysis, faster checksum) – Parser for third party storage (Facebook, Google Pictures) – Server side storage of data (on AWS)
  • 24. 24 What about the Query Side? • I want a synthesized view of individual files • Time ordered • Duplicate or irrelevant events eliminated • Can use the aggregation framework to generate this data • The ability to link data across multiple machines • The ability to link data across multiple services
  • 25. 25 Summary • Event Sourcing : Capture the state as first class objects • CQRS : Optimise differently for commands and queries • Not an architectural design pattern • MongoDB ideally suited to build both event store and query store • Use different storage engines depending on use case • The aggregation framework generates summary data

Editor's Notes

  1. 1495 Luca Pacioli invented double entry accounting. Born Borgo Sansepolcro, Tuscany. A write only log.
  2. This is what we do when we do our own backups to an external drive. We drag and drop the disks.
  3. This is what we do when we do our own backups to an external drive. We drag and drop the disks.
  4. Now we track the source and target. When the backup was done. We are storing events about the system.
  5. Now we track the source and target. When the backup was done. We are storing events about the system.
  6. The state of the file is defined by the events. The events represent uploaded blocks but they are basically almost redundant. It’s the meta data that matters. Now we can reover from file renames and deletions. Edits and the ability to restart very large files after reboot. Event sourced systems work really well for intermittenly connected devices. Whats more back companies don’t ever coalesce these blocks. Why because they are checksumed and deduped.
  7. Commands : as opposed to methods on an object. Bertrand Meyer. Void commands queries with node side effects.
  8. Nathan Marz