SlideShare une entreprise Scribd logo
1  sur  11
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...Amazon Web Services Korea
 
Azure Application insights - An Introduction
Azure Application insights - An IntroductionAzure Application insights - An Introduction
Azure Application insights - An IntroductionMatthias Güntert
 
The Art of Discovering Bounded Contexts
The Art of Discovering Bounded ContextsThe Art of Discovering Bounded Contexts
The Art of Discovering Bounded ContextsNick Tune
 
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트) IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트) Amazon Web Services Korea
 
Deep Dive - Infrastructure as Code
Deep Dive - Infrastructure as CodeDeep Dive - Infrastructure as Code
Deep Dive - Infrastructure as CodeAmazon Web Services
 
APIs in a Microservice Architecture
APIs in a Microservice ArchitectureAPIs in a Microservice Architecture
APIs in a Microservice ArchitectureWSO2
 
Microservices with event source and CQRS
Microservices with event source and CQRSMicroservices with event source and CQRS
Microservices with event source and CQRSMd Ayub Ali Sarker
 
Open Service Broker APIとKubernetes Service Catalog #k8sjp
Open Service Broker APIとKubernetes Service Catalog #k8sjpOpen Service Broker APIとKubernetes Service Catalog #k8sjp
Open Service Broker APIとKubernetes Service Catalog #k8sjpToshiaki Maki
 
Azure DDoS Protection Standard
Azure DDoS Protection StandardAzure DDoS Protection Standard
Azure DDoS Protection Standardarnaudlh
 
마이크로서비스를 위한 AWS 아키텍처 패턴 및 모범 사례 - AWS Summit Seoul 2017
마이크로서비스를 위한 AWS 아키텍처 패턴 및 모범 사례 - AWS Summit Seoul 2017마이크로서비스를 위한 AWS 아키텍처 패턴 및 모범 사례 - AWS Summit Seoul 2017
마이크로서비스를 위한 AWS 아키텍처 패턴 및 모범 사례 - AWS Summit Seoul 2017Amazon Web Services Korea
 
[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축
[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축
[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축Ji-Woong Choi
 
CI/CD on AWS Deploy Everything All the Time
CI/CD on AWS Deploy Everything All the TimeCI/CD on AWS Deploy Everything All the Time
CI/CD on AWS Deploy Everything All the TimeAmazon Web Services
 
Microservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsMicroservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsAraf Karsh Hamid
 
Microservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitectureMicroservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitecturePaul Mooney
 
CQRS and Event Sourcing
CQRS and Event Sourcing CQRS and Event Sourcing
CQRS and Event Sourcing Inho Kang
 
Azure kubernetes service
Azure kubernetes serviceAzure kubernetes service
Azure kubernetes serviceVishwas N
 
Microservices Design Patterns
Microservices Design PatternsMicroservices Design Patterns
Microservices Design PatternsHaim Michael
 

Tendances (20)

[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
 
Azure Application insights - An Introduction
Azure Application insights - An IntroductionAzure Application insights - An Introduction
Azure Application insights - An Introduction
 
The Art of Discovering Bounded Contexts
The Art of Discovering Bounded ContextsThe Art of Discovering Bounded Contexts
The Art of Discovering Bounded Contexts
 
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트) IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
IDC 서버 몽땅 AWS로 이전하기 위한 5가지 방법 - 윤석찬 (AWS 테크에반젤리스트)
 
Deep Dive - Infrastructure as Code
Deep Dive - Infrastructure as CodeDeep Dive - Infrastructure as Code
Deep Dive - Infrastructure as Code
 
Kubernetes Basics
Kubernetes BasicsKubernetes Basics
Kubernetes Basics
 
APIs in a Microservice Architecture
APIs in a Microservice ArchitectureAPIs in a Microservice Architecture
APIs in a Microservice Architecture
 
Microservices with event source and CQRS
Microservices with event source and CQRSMicroservices with event source and CQRS
Microservices with event source and CQRS
 
Open Service Broker APIとKubernetes Service Catalog #k8sjp
Open Service Broker APIとKubernetes Service Catalog #k8sjpOpen Service Broker APIとKubernetes Service Catalog #k8sjp
Open Service Broker APIとKubernetes Service Catalog #k8sjp
 
Azure DDoS Protection Standard
Azure DDoS Protection StandardAzure DDoS Protection Standard
Azure DDoS Protection Standard
 
Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservices
 
마이크로서비스를 위한 AWS 아키텍처 패턴 및 모범 사례 - AWS Summit Seoul 2017
마이크로서비스를 위한 AWS 아키텍처 패턴 및 모범 사례 - AWS Summit Seoul 2017마이크로서비스를 위한 AWS 아키텍처 패턴 및 모범 사례 - AWS Summit Seoul 2017
마이크로서비스를 위한 AWS 아키텍처 패턴 및 모범 사례 - AWS Summit Seoul 2017
 
[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축
[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축
[오픈소스컨설팅]쿠버네티스를 활용한 개발환경 구축
 
AKS
AKSAKS
AKS
 
CI/CD on AWS Deploy Everything All the Time
CI/CD on AWS Deploy Everything All the TimeCI/CD on AWS Deploy Everything All the Time
CI/CD on AWS Deploy Everything All the Time
 
Microservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsMicroservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native Apps
 
Microservice vs. Monolithic Architecture
Microservice vs. Monolithic ArchitectureMicroservice vs. Monolithic Architecture
Microservice vs. Monolithic Architecture
 
CQRS and Event Sourcing
CQRS and Event Sourcing CQRS and Event Sourcing
CQRS and Event Sourcing
 
Azure kubernetes service
Azure kubernetes serviceAzure kubernetes service
Azure kubernetes service
 
Microservices Design Patterns
Microservices Design PatternsMicroservices Design Patterns
Microservices Design Patterns
 

En vedette

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
 
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
 

En vedette (9)

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
 
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
 

Similaire à 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
 

Similaire à 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
 

Dernier

Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 

Dernier (20)

Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 

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