SlideShare una empresa de Scribd logo
1 de 11
Descargar para leer sin conexión
Microservice
Architecture
with CQRS & Event Sourcing
Ben Wilcock
Freelance Software Architect [UK]
https://twitter.com/benbravo73
https://www.linkedin.com/in/benwilcock
http://benwilcock.wordpress.com
What is CQRS?
2
‘Command & Query Responsibility Segregation’
CQRS is an architectural pattern for developing software
whereby the bits of the system that are responsible for changing
the system’s state (the ‘write-parts’) are physically separated
from the bits of the system that manage views (the ‘read-parts’)
This is in contrast to CRUD architecture where traditionally the
same component has responsibility for both the reads (the
views) and the writes (the state changes)
What is Event Sourcing (ES)?
3
Event Sourcing uses a timeline to describe state
When Event Sourcing, state is recorded as a complete series of
the events resulting from the actions taken within the domain
These persisted events can then be used to re-establish the state
of the actors within the domain at any point in time
This is in contrast to CRUD architecture where traditionally only
the current state of an entity is stored (and not the history of
events describing how it arrived at this current state)
Event sourcing complements CQRS, but CQRS does not require
event-sourcing in order to be successful
What are the Principles behind CQRS/ES?
Separation of Concerns (SoC)
A design principle for separating a
computer program into distinct
sections, such that each section
addresses a separate concern
Do one thing and do it well
A philosophy at the heart of UNIX
development that leads to small and
highly-cohesive applications
Event-Driven Architecture
Also known as Message-driven
architecture, this is a software
architecture pattern that promotes
the production, detection,
consumption and reaction to events
over other forms of integration
4
Domain-Driven Design (DDD)
A software development approach
whereby the implementation is
strongly linked to the business
domain in which it’s used
Loose-coupling
An approach to interconnecting
components such that those
components depend on each other to
the least extent practicable
Event sourcing
A mechanism for persisting
application's state by storing the
history of events or changes that
caused the system to arrive at its
current state
What are the Benefits of CQRS?
Scalability
In mosts systems the number of reads
vastly exceeds writes - yet the architecture
rarely reflects this
In CQRS the read-side is separate from the
write-side, so each can be scaled and
performance-optimised independently
Simplicity
In most systems a single model is used to
manage, describe, store and view data
This sounds simple, but it adds complexity
as contradicting requirements (writing and
reading) must be handled by a single model
With CQRS the write-model and the read-
model can be different
Flexibility
The clear separation of methods that
change state from the methods that view
state makes change simpler
Change can be made with greater
confidence and with more predictable
effects
Business Focus
Commands are intuitive and instantly
recognisable as business related actions
In CQRS this business focus together with
Domain Driven Design can result in
applications that are more responsive to
change and cheaper to maintain
5
What are the Benefits of Event Sourcing?
History has Business Value
By storing events, you never discard
information that may have future value
Events allow you to see the state of the
system at any point in the past
You can use this insight to answer historical
business questions as they arise
Easy Integration
Events are also a useful way of
communicating with other systems
Integration based on events offers very low
levels of coupling as the event producers
don’t need to know anything about the event
consumers (and vice versa)
Simplicity
By saving only events, you are avoiding the
complex business of persisting complex
domain objects to a relational store -
otherwise known as the “object-relational
impedance mismatch”
Performance
Events are simple, standalone and
immutable, so you can use faster append-
only operations to store them
Flexibility
A sequence of events can be "projected" into
any desired structural representation or
"view" at any time
6
What does CQRS/ES Architecture look like?
Multiple views
or ‘projections’
can be built to
satisfy
disparate
client
requirements
& limitations
Integrations are
unlimited, event-based
and loosely-coupled
Interactions are
modeled as
simple
‘Commands’,
‘Events’ and
‘Queries’
Events are
stored and
then forwarded
to the event
exchange
command-side
(Rules and Behavior)
query-side
(Presentation and Facts)
7
Read-side can
be scaled,
optimised and
secured
independently
of the Write-
side
Command
processing
results in
Events being
created
Why choose CQRS/ES for your architecture?
Here are my Top 5 reasons to consider CQRS/ES for your architecture
1. The number of reads, queries and views usually far exceeds the number of writes,
so a separation of these concerns can make development simpler and faster
2. Events are ubiquitous; every business process has them, so modelling systems on
events and storing past events has real business value
3. Often when choosing CRUD architecture, we under-estimate the complexity of
the logic required to manage the life-cycle of our business entities - this has
major impacts later, particularly on scalability
4. Event-based integration is far easier to manage and maintain than traditional
‘canonical model’ based integration techniques
5. Having independent data projections and views is really useful, particularly if you
have multiple disparate clients that require access to similar information - such as
mobile, web, public api’s etc.
8
Who uses CQRS & Event Sourcing?
The CQRS / ES approach to application architecture works well with Microservices, so it’s
popular with organisations that need cost effective scaling, organisations like...
9
An Industry Perspective on CQRS/ES
10
CQRS [Axon] - ASSESS
CQRS can work very well in specific places.
In those specific situations, however, a lot
of work is left to the developer to properly
execute CQRS.
Axon is a framework that can help with this
on the JVM, and we’ve used it with some
success.
Although it’s not perfect, it continues to
evolve and may make much more sense
than trying to write everything from
scratch.
My Axon Sample: https://goo.gl/uGGISx
Event Sourcing - TRIAL
Event Sourcing ensures that all changes to
application state are stored as a sequence of
events.
Complementary to the capture of
meaningful business events, the technique
has positive implications for analytics in
driving greater customer insight.
Not only can we query events, we can also
use the event log as history, and as a
foundation to automatically adjust the state
to cope with retroactive changes.
CQRS/ES is still considered a new and innovative approach to software design. Here’s what
ThoughtWorks said about CQRS and Event Sourcing in their 2015 Tech Radar...
Hungry for more?
Check out my Axon based CQRS/ES
Microservice sample code on GitHub:
https://goo.gl/uGGISx
For a conversation about how I could help your
team to achieve great things, contact me using
the social media links below:
11
Ben Wilcock
Freelance Software Architect [UK]
https://twitter.com/benbravo73
https://www.linkedin.com/in/benwilcock
http://benwilcock.wordpress.com

Más contenido relacionado

La actualidad más candente

A Brief Look at Serverless Architecture
A Brief Look at Serverless ArchitectureA Brief Look at Serverless Architecture
A Brief Look at Serverless ArchitectureAmazon Web Services
 
Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservicesAnil Allewar
 
우아한 모노리스
우아한 모노리스우아한 모노리스
우아한 모노리스Arawn Park
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAgile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAraf Karsh Hamid
 
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQEvent Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQAraf Karsh Hamid
 
Event Sourcing: Introduction & Challenges
Event Sourcing: Introduction & ChallengesEvent Sourcing: Introduction & Challenges
Event Sourcing: Introduction & ChallengesMichael Plöd
 
Axon Framework, Exploring CQRS and Event Sourcing Architecture
Axon Framework, Exploring CQRS and Event Sourcing ArchitectureAxon Framework, Exploring CQRS and Event Sourcing Architecture
Axon Framework, Exploring CQRS and Event Sourcing ArchitectureAshutosh Jadhav
 
20180726 AWS KRUG - RDS Aurora에 40억건 데이터 입력하기
20180726 AWS KRUG - RDS Aurora에 40억건 데이터 입력하기20180726 AWS KRUG - RDS Aurora에 40억건 데이터 입력하기
20180726 AWS KRUG - RDS Aurora에 40억건 데이터 입력하기Jongwon Han
 
Amazon kinesis와 elasticsearch service로 만드는 실시간 데이터 분석 플랫폼 :: 박철수 :: AWS Summi...
Amazon kinesis와 elasticsearch service로 만드는 실시간 데이터 분석 플랫폼 :: 박철수 :: AWS Summi...Amazon kinesis와 elasticsearch service로 만드는 실시간 데이터 분석 플랫폼 :: 박철수 :: AWS Summi...
Amazon kinesis와 elasticsearch service로 만드는 실시간 데이터 분석 플랫폼 :: 박철수 :: AWS Summi...Amazon Web Services Korea
 
Microservices Part 3 Service Mesh and Kafka
Microservices Part 3 Service Mesh and KafkaMicroservices Part 3 Service Mesh and Kafka
Microservices Part 3 Service Mesh and KafkaAraf Karsh Hamid
 
Prometheus – a next-gen Monitoring System
Prometheus – a next-gen Monitoring SystemPrometheus – a next-gen Monitoring System
Prometheus – a next-gen Monitoring SystemFabian Reinartz
 
Service Mesh - Observability
Service Mesh - ObservabilityService Mesh - Observability
Service Mesh - ObservabilityAraf Karsh Hamid
 
MSA 전략 2: 마이크로서비스, 어떻게 구현할 것인가?
MSA 전략 2: 마이크로서비스, 어떻게 구현할 것인가?MSA 전략 2: 마이크로서비스, 어떻게 구현할 것인가?
MSA 전략 2: 마이크로서비스, 어떻게 구현할 것인가?VMware Tanzu Korea
 
Domain Driven Design Demonstrated
Domain Driven Design Demonstrated Domain Driven Design Demonstrated
Domain Driven Design Demonstrated Alan Christensen
 
Designing loosely coupled services
Designing loosely coupled servicesDesigning loosely coupled services
Designing loosely coupled servicesChris Richardson
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architectureThe Software House
 
Microservice architecture design principles
Microservice architecture design principlesMicroservice architecture design principles
Microservice architecture design principlesSanjoy Kumar Roy
 

La actualidad más candente (20)

A Brief Look at Serverless Architecture
A Brief Look at Serverless ArchitectureA Brief Look at Serverless Architecture
A Brief Look at Serverless Architecture
 
Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservices
 
우아한 모노리스
우아한 모노리스우아한 모노리스
우아한 모노리스
 
Agile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven DesignAgile, User Stories, Domain Driven Design
Agile, User Stories, Domain Driven Design
 
Architecture: Microservices
Architecture: MicroservicesArchitecture: Microservices
Architecture: Microservices
 
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQEvent Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQ
 
Event Sourcing: Introduction & Challenges
Event Sourcing: Introduction & ChallengesEvent Sourcing: Introduction & Challenges
Event Sourcing: Introduction & Challenges
 
Axon Framework, Exploring CQRS and Event Sourcing Architecture
Axon Framework, Exploring CQRS and Event Sourcing ArchitectureAxon Framework, Exploring CQRS and Event Sourcing Architecture
Axon Framework, Exploring CQRS and Event Sourcing Architecture
 
20180726 AWS KRUG - RDS Aurora에 40억건 데이터 입력하기
20180726 AWS KRUG - RDS Aurora에 40억건 데이터 입력하기20180726 AWS KRUG - RDS Aurora에 40억건 데이터 입력하기
20180726 AWS KRUG - RDS Aurora에 40억건 데이터 입력하기
 
Amazon kinesis와 elasticsearch service로 만드는 실시간 데이터 분석 플랫폼 :: 박철수 :: AWS Summi...
Amazon kinesis와 elasticsearch service로 만드는 실시간 데이터 분석 플랫폼 :: 박철수 :: AWS Summi...Amazon kinesis와 elasticsearch service로 만드는 실시간 데이터 분석 플랫폼 :: 박철수 :: AWS Summi...
Amazon kinesis와 elasticsearch service로 만드는 실시간 데이터 분석 플랫폼 :: 박철수 :: AWS Summi...
 
Domain Driven Design
Domain Driven Design Domain Driven Design
Domain Driven Design
 
Microservices Part 3 Service Mesh and Kafka
Microservices Part 3 Service Mesh and KafkaMicroservices Part 3 Service Mesh and Kafka
Microservices Part 3 Service Mesh and Kafka
 
Prometheus – a next-gen Monitoring System
Prometheus – a next-gen Monitoring SystemPrometheus – a next-gen Monitoring System
Prometheus – a next-gen Monitoring System
 
Service Mesh - Observability
Service Mesh - ObservabilityService Mesh - Observability
Service Mesh - Observability
 
MSA 전략 2: 마이크로서비스, 어떻게 구현할 것인가?
MSA 전략 2: 마이크로서비스, 어떻게 구현할 것인가?MSA 전략 2: 마이크로서비스, 어떻게 구현할 것인가?
MSA 전략 2: 마이크로서비스, 어떻게 구현할 것인가?
 
Elastic-Engineering
Elastic-EngineeringElastic-Engineering
Elastic-Engineering
 
Domain Driven Design Demonstrated
Domain Driven Design Demonstrated Domain Driven Design Demonstrated
Domain Driven Design Demonstrated
 
Designing loosely coupled services
Designing loosely coupled servicesDesigning loosely coupled services
Designing loosely coupled services
 
Design patterns for microservice architecture
Design patterns for microservice architectureDesign patterns for microservice architecture
Design patterns for microservice architecture
 
Microservice architecture design principles
Microservice architecture design principlesMicroservice architecture design principles
Microservice architecture design principles
 

Destacado

Microservices - java ee vs spring boot and spring cloud
Microservices - java ee vs spring boot and spring cloudMicroservices - java ee vs spring boot and spring cloud
Microservices - java ee vs spring boot and spring cloudBen Wilcock
 
Introduction to Kafka with Spring Integration
Introduction to Kafka with Spring IntegrationIntroduction to Kafka with Spring Integration
Introduction to Kafka with Spring IntegrationBorislav Markov
 
Spring integration with the Java DSL
Spring integration with the Java DSLSpring integration with the Java DSL
Spring integration with the Java DSLBen Wilcock
 
Introduction To Functional Reactive Programming Poznan
Introduction To Functional Reactive Programming PoznanIntroduction To Functional Reactive Programming Poznan
Introduction To Functional Reactive Programming PoznanEliasz Sawicki
 
Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...Mario Fusco
 
From object oriented to functional domain modeling
From object oriented to functional domain modelingFrom object oriented to functional domain modeling
From object oriented to functional domain modelingMario Fusco
 
Integration Patterns and Anti-Patterns for Microservices Architectures
Integration Patterns and Anti-Patterns for Microservices ArchitecturesIntegration Patterns and Anti-Patterns for Microservices Architectures
Integration Patterns and Anti-Patterns for Microservices ArchitecturesApcera
 
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...Chris Richardson
 
Scaling wix with microservices architecture devoxx London 2015
Scaling wix with microservices architecture devoxx London 2015Scaling wix with microservices architecture devoxx London 2015
Scaling wix with microservices architecture devoxx London 2015Aviran Mordo
 
Recommender system algorithm and architecture
Recommender system algorithm and architectureRecommender system algorithm and architecture
Recommender system algorithm and architectureLiang Xiang
 

Destacado (10)

Microservices - java ee vs spring boot and spring cloud
Microservices - java ee vs spring boot and spring cloudMicroservices - java ee vs spring boot and spring cloud
Microservices - java ee vs spring boot and spring cloud
 
Introduction to Kafka with Spring Integration
Introduction to Kafka with Spring IntegrationIntroduction to Kafka with Spring Integration
Introduction to Kafka with Spring Integration
 
Spring integration with the Java DSL
Spring integration with the Java DSLSpring integration with the Java DSL
Spring integration with the Java DSL
 
Introduction To Functional Reactive Programming Poznan
Introduction To Functional Reactive Programming PoznanIntroduction To Functional Reactive Programming Poznan
Introduction To Functional Reactive Programming Poznan
 
Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...
 
From object oriented to functional domain modeling
From object oriented to functional domain modelingFrom object oriented to functional domain modeling
From object oriented to functional domain modeling
 
Integration Patterns and Anti-Patterns for Microservices Architectures
Integration Patterns and Anti-Patterns for Microservices ArchitecturesIntegration Patterns and Anti-Patterns for Microservices Architectures
Integration Patterns and Anti-Patterns for Microservices Architectures
 
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
 
Scaling wix with microservices architecture devoxx London 2015
Scaling wix with microservices architecture devoxx London 2015Scaling wix with microservices architecture devoxx London 2015
Scaling wix with microservices architecture devoxx London 2015
 
Recommender system algorithm and architecture
Recommender system algorithm and architectureRecommender system algorithm and architecture
Recommender system algorithm and architecture
 

Similar a Microservice Architecture with CQRS and Event Sourcing

10 Key Digital Infrastructure Considerations
10 Key Digital Infrastructure Considerations10 Key Digital Infrastructure Considerations
10 Key Digital Infrastructure ConsiderationsCognizant
 
SaaS Application Scalability: Best Practices from Architecture to Cloud Infra...
SaaS Application Scalability: Best Practices from Architecture to Cloud Infra...SaaS Application Scalability: Best Practices from Architecture to Cloud Infra...
SaaS Application Scalability: Best Practices from Architecture to Cloud Infra...riyak40
 
International Journal of Computer Science, Engineering and Information Techno...
International Journal of Computer Science, Engineering and Information Techno...International Journal of Computer Science, Engineering and Information Techno...
International Journal of Computer Science, Engineering and Information Techno...ijcseit
 
CONFIGURATION INERPSAAS MULTI-TENANCY
CONFIGURATION INERPSAAS MULTI-TENANCYCONFIGURATION INERPSAAS MULTI-TENANCY
CONFIGURATION INERPSAAS MULTI-TENANCYijcseit
 
Configuration inerpsaas multi tenancy
Configuration inerpsaas multi tenancyConfiguration inerpsaas multi tenancy
Configuration inerpsaas multi tenancyijcseit
 
Modern webtechnologies
Modern webtechnologiesModern webtechnologies
Modern webtechnologiesBesjan Xhika
 
Dynamic Service Level Agreement Verification in Cloud Computing
Dynamic Service Level Agreement Verification in Cloud Computing Dynamic Service Level Agreement Verification in Cloud Computing
Dynamic Service Level Agreement Verification in Cloud Computing IJCSIS Research Publications
 
Cisco Secure Enclaves Architecture
Cisco Secure Enclaves ArchitectureCisco Secure Enclaves Architecture
Cisco Secure Enclaves ArchitectureCisco Russia
 
Microservices: A Step Towards Modernizing Healthcare Applications
Microservices: A Step Towards Modernizing Healthcare ApplicationsMicroservices: A Step Towards Modernizing Healthcare Applications
Microservices: A Step Towards Modernizing Healthcare ApplicationsCitiusTech
 
Cloud Design Patterns - PRESCRIPTIVE ARCHITECTURE GUIDANCE FOR CLOUD APPLICAT...
Cloud Design Patterns - PRESCRIPTIVE ARCHITECTURE GUIDANCE FOR CLOUD APPLICAT...Cloud Design Patterns - PRESCRIPTIVE ARCHITECTURE GUIDANCE FOR CLOUD APPLICAT...
Cloud Design Patterns - PRESCRIPTIVE ARCHITECTURE GUIDANCE FOR CLOUD APPLICAT...David J Rosenthal
 
Cloud MicroService Architecture
Cloud MicroService ArchitectureCloud MicroService Architecture
Cloud MicroService ArchitectureYakov Liskoff
 
Correlation Architecture
Correlation ArchitectureCorrelation Architecture
Correlation Architecturesboray
 
BUSINESS SILOS INTEGRATION USING SERVICE ORIENTED ARCHITECTURE
BUSINESS SILOS INTEGRATION USING SERVICE ORIENTED ARCHITECTUREBUSINESS SILOS INTEGRATION USING SERVICE ORIENTED ARCHITECTURE
BUSINESS SILOS INTEGRATION USING SERVICE ORIENTED ARCHITECTUREIJCSEA Journal
 
WebApplicationArchitectureAzure.pptx
WebApplicationArchitectureAzure.pptxWebApplicationArchitectureAzure.pptx
WebApplicationArchitectureAzure.pptxPrashanth Panduranga
 
WebApplicationArchitectureAzure.pdf
WebApplicationArchitectureAzure.pdfWebApplicationArchitectureAzure.pdf
WebApplicationArchitectureAzure.pdfPrashanth Panduranga
 
Reimagine Application Modernization with Serverless Architecture
Reimagine Application Modernization with Serverless ArchitectureReimagine Application Modernization with Serverless Architecture
Reimagine Application Modernization with Serverless ArchitectureOpteamix LLC
 

Similar a Microservice Architecture with CQRS and Event Sourcing (20)

10 Key Digital Infrastructure Considerations
10 Key Digital Infrastructure Considerations10 Key Digital Infrastructure Considerations
10 Key Digital Infrastructure Considerations
 
SaaS Application Scalability: Best Practices from Architecture to Cloud Infra...
SaaS Application Scalability: Best Practices from Architecture to Cloud Infra...SaaS Application Scalability: Best Practices from Architecture to Cloud Infra...
SaaS Application Scalability: Best Practices from Architecture to Cloud Infra...
 
International Journal of Computer Science, Engineering and Information Techno...
International Journal of Computer Science, Engineering and Information Techno...International Journal of Computer Science, Engineering and Information Techno...
International Journal of Computer Science, Engineering and Information Techno...
 
CONFIGURATION INERPSAAS MULTI-TENANCY
CONFIGURATION INERPSAAS MULTI-TENANCYCONFIGURATION INERPSAAS MULTI-TENANCY
CONFIGURATION INERPSAAS MULTI-TENANCY
 
Configuration inerpsaas multi tenancy
Configuration inerpsaas multi tenancyConfiguration inerpsaas multi tenancy
Configuration inerpsaas multi tenancy
 
Modern webtechnologies
Modern webtechnologiesModern webtechnologies
Modern webtechnologies
 
An Overview of Windows Azure
An Overview of Windows AzureAn Overview of Windows Azure
An Overview of Windows Azure
 
NOS DevDays 2014 | CQRS+ES
NOS DevDays 2014 | CQRS+ESNOS DevDays 2014 | CQRS+ES
NOS DevDays 2014 | CQRS+ES
 
Dynamic Service Level Agreement Verification in Cloud Computing
Dynamic Service Level Agreement Verification in Cloud Computing Dynamic Service Level Agreement Verification in Cloud Computing
Dynamic Service Level Agreement Verification in Cloud Computing
 
Cisco Secure Enclaves Architecture
Cisco Secure Enclaves ArchitectureCisco Secure Enclaves Architecture
Cisco Secure Enclaves Architecture
 
Refactoring to Microservice Architecture
Refactoring to Microservice ArchitectureRefactoring to Microservice Architecture
Refactoring to Microservice Architecture
 
Microservices: A Step Towards Modernizing Healthcare Applications
Microservices: A Step Towards Modernizing Healthcare ApplicationsMicroservices: A Step Towards Modernizing Healthcare Applications
Microservices: A Step Towards Modernizing Healthcare Applications
 
Cloud Design Patterns - PRESCRIPTIVE ARCHITECTURE GUIDANCE FOR CLOUD APPLICAT...
Cloud Design Patterns - PRESCRIPTIVE ARCHITECTURE GUIDANCE FOR CLOUD APPLICAT...Cloud Design Patterns - PRESCRIPTIVE ARCHITECTURE GUIDANCE FOR CLOUD APPLICAT...
Cloud Design Patterns - PRESCRIPTIVE ARCHITECTURE GUIDANCE FOR CLOUD APPLICAT...
 
Cloud MicroService Architecture
Cloud MicroService ArchitectureCloud MicroService Architecture
Cloud MicroService Architecture
 
Governance in the age of cloud
Governance in the age of cloudGovernance in the age of cloud
Governance in the age of cloud
 
Correlation Architecture
Correlation ArchitectureCorrelation Architecture
Correlation Architecture
 
BUSINESS SILOS INTEGRATION USING SERVICE ORIENTED ARCHITECTURE
BUSINESS SILOS INTEGRATION USING SERVICE ORIENTED ARCHITECTUREBUSINESS SILOS INTEGRATION USING SERVICE ORIENTED ARCHITECTURE
BUSINESS SILOS INTEGRATION USING SERVICE ORIENTED ARCHITECTURE
 
WebApplicationArchitectureAzure.pptx
WebApplicationArchitectureAzure.pptxWebApplicationArchitectureAzure.pptx
WebApplicationArchitectureAzure.pptx
 
WebApplicationArchitectureAzure.pdf
WebApplicationArchitectureAzure.pdfWebApplicationArchitectureAzure.pdf
WebApplicationArchitectureAzure.pdf
 
Reimagine Application Modernization with Serverless Architecture
Reimagine Application Modernization with Serverless ArchitectureReimagine Application Modernization with Serverless Architecture
Reimagine Application Modernization with Serverless Architecture
 

Último

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 

Último (20)

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 

Microservice Architecture with CQRS and Event Sourcing

  • 1. Microservice Architecture with CQRS & Event Sourcing Ben Wilcock Freelance Software Architect [UK] https://twitter.com/benbravo73 https://www.linkedin.com/in/benwilcock http://benwilcock.wordpress.com
  • 2. What is CQRS? 2 ‘Command & Query Responsibility Segregation’ CQRS is an architectural pattern for developing software whereby the bits of the system that are responsible for changing the system’s state (the ‘write-parts’) are physically separated from the bits of the system that manage views (the ‘read-parts’) This is in contrast to CRUD architecture where traditionally the same component has responsibility for both the reads (the views) and the writes (the state changes)
  • 3. What is Event Sourcing (ES)? 3 Event Sourcing uses a timeline to describe state When Event Sourcing, state is recorded as a complete series of the events resulting from the actions taken within the domain These persisted events can then be used to re-establish the state of the actors within the domain at any point in time This is in contrast to CRUD architecture where traditionally only the current state of an entity is stored (and not the history of events describing how it arrived at this current state) Event sourcing complements CQRS, but CQRS does not require event-sourcing in order to be successful
  • 4. What are the Principles behind CQRS/ES? Separation of Concerns (SoC) A design principle for separating a computer program into distinct sections, such that each section addresses a separate concern Do one thing and do it well A philosophy at the heart of UNIX development that leads to small and highly-cohesive applications Event-Driven Architecture Also known as Message-driven architecture, this is a software architecture pattern that promotes the production, detection, consumption and reaction to events over other forms of integration 4 Domain-Driven Design (DDD) A software development approach whereby the implementation is strongly linked to the business domain in which it’s used Loose-coupling An approach to interconnecting components such that those components depend on each other to the least extent practicable Event sourcing A mechanism for persisting application's state by storing the history of events or changes that caused the system to arrive at its current state
  • 5. What are the Benefits of CQRS? Scalability In mosts systems the number of reads vastly exceeds writes - yet the architecture rarely reflects this In CQRS the read-side is separate from the write-side, so each can be scaled and performance-optimised independently Simplicity In most systems a single model is used to manage, describe, store and view data This sounds simple, but it adds complexity as contradicting requirements (writing and reading) must be handled by a single model With CQRS the write-model and the read- model can be different Flexibility The clear separation of methods that change state from the methods that view state makes change simpler Change can be made with greater confidence and with more predictable effects Business Focus Commands are intuitive and instantly recognisable as business related actions In CQRS this business focus together with Domain Driven Design can result in applications that are more responsive to change and cheaper to maintain 5
  • 6. What are the Benefits of Event Sourcing? History has Business Value By storing events, you never discard information that may have future value Events allow you to see the state of the system at any point in the past You can use this insight to answer historical business questions as they arise Easy Integration Events are also a useful way of communicating with other systems Integration based on events offers very low levels of coupling as the event producers don’t need to know anything about the event consumers (and vice versa) Simplicity By saving only events, you are avoiding the complex business of persisting complex domain objects to a relational store - otherwise known as the “object-relational impedance mismatch” Performance Events are simple, standalone and immutable, so you can use faster append- only operations to store them Flexibility A sequence of events can be "projected" into any desired structural representation or "view" at any time 6
  • 7. What does CQRS/ES Architecture look like? Multiple views or ‘projections’ can be built to satisfy disparate client requirements & limitations Integrations are unlimited, event-based and loosely-coupled Interactions are modeled as simple ‘Commands’, ‘Events’ and ‘Queries’ Events are stored and then forwarded to the event exchange command-side (Rules and Behavior) query-side (Presentation and Facts) 7 Read-side can be scaled, optimised and secured independently of the Write- side Command processing results in Events being created
  • 8. Why choose CQRS/ES for your architecture? Here are my Top 5 reasons to consider CQRS/ES for your architecture 1. The number of reads, queries and views usually far exceeds the number of writes, so a separation of these concerns can make development simpler and faster 2. Events are ubiquitous; every business process has them, so modelling systems on events and storing past events has real business value 3. Often when choosing CRUD architecture, we under-estimate the complexity of the logic required to manage the life-cycle of our business entities - this has major impacts later, particularly on scalability 4. Event-based integration is far easier to manage and maintain than traditional ‘canonical model’ based integration techniques 5. Having independent data projections and views is really useful, particularly if you have multiple disparate clients that require access to similar information - such as mobile, web, public api’s etc. 8
  • 9. Who uses CQRS & Event Sourcing? The CQRS / ES approach to application architecture works well with Microservices, so it’s popular with organisations that need cost effective scaling, organisations like... 9
  • 10. An Industry Perspective on CQRS/ES 10 CQRS [Axon] - ASSESS CQRS can work very well in specific places. In those specific situations, however, a lot of work is left to the developer to properly execute CQRS. Axon is a framework that can help with this on the JVM, and we’ve used it with some success. Although it’s not perfect, it continues to evolve and may make much more sense than trying to write everything from scratch. My Axon Sample: https://goo.gl/uGGISx Event Sourcing - TRIAL Event Sourcing ensures that all changes to application state are stored as a sequence of events. Complementary to the capture of meaningful business events, the technique has positive implications for analytics in driving greater customer insight. Not only can we query events, we can also use the event log as history, and as a foundation to automatically adjust the state to cope with retroactive changes. CQRS/ES is still considered a new and innovative approach to software design. Here’s what ThoughtWorks said about CQRS and Event Sourcing in their 2015 Tech Radar...
  • 11. Hungry for more? Check out my Axon based CQRS/ES Microservice sample code on GitHub: https://goo.gl/uGGISx For a conversation about how I could help your team to achieve great things, contact me using the social media links below: 11 Ben Wilcock Freelance Software Architect [UK] https://twitter.com/benbravo73 https://www.linkedin.com/in/benwilcock http://benwilcock.wordpress.com