cqrs: high availability, scabaility, and maintainability
DESCRIPTION
Present at CodeFest 2014 Command Query Responsibility Segregation (CQRS) and Event Sourcing (ES) are popular patterns for designing and building large-scale, distributed systems. The patterns & practices team at Microsoft set out on a journey to better understand these patterns and the benefits they can provide to developers. In this talk, we’ll review what the team learned along the way and provide insight into how your applications can benefit from these ideas.TRANSCRIPT
![Page 1: CQRS: high availability, scabaility, and maintainability](https://reader033.vdocument.in/reader033/viewer/2022061206/548215e9b4af9f21758b459a/html5/thumbnails/1.jpg)
Exploring CQRS and Event SourcingA journey into high scalability, availability, and maintainability with AzureChristopher Bennagepatterns & practicesmicrosoft.com/practices
![Page 2: CQRS: high availability, scabaility, and maintainability](https://reader033.vdocument.in/reader033/viewer/2022061206/548215e9b4af9f21758b459a/html5/thumbnails/2.jpg)
![Page 3: CQRS: high availability, scabaility, and maintainability](https://reader033.vdocument.in/reader033/viewer/2022061206/548215e9b4af9f21758b459a/html5/thumbnails/3.jpg)
•Scale with predictable cost•Scale at unpredictable times•Be continuously available
New RequirementsArchitecting for Today
![Page 4: CQRS: high availability, scabaility, and maintainability](https://reader033.vdocument.in/reader033/viewer/2022061206/548215e9b4af9f21758b459a/html5/thumbnails/4.jpg)
CommandQuery Responsibility Segregation
What is CQRS?Separating Reads from Writes
An architectural pattern that separates Commands (that change state) from Queries (that only read state).
![Page 5: CQRS: high availability, scabaility, and maintainability](https://reader033.vdocument.in/reader033/viewer/2022061206/548215e9b4af9f21758b459a/html5/thumbnails/5.jpg)
N-Tier20th Century Architecture
Domain Logic
Presentation
Persistence
Commands Queries
![Page 6: CQRS: high availability, scabaility, and maintainability](https://reader033.vdocument.in/reader033/viewer/2022061206/548215e9b4af9f21758b459a/html5/thumbnails/6.jpg)
![Page 7: CQRS: high availability, scabaility, and maintainability](https://reader033.vdocument.in/reader033/viewer/2022061206/548215e9b4af9f21758b459a/html5/thumbnails/7.jpg)
Applying CQRSSeparate Data Stores
Presentation
Validation
Commands
Domain Logic
Data persistence
Queries (generate DTOs)
![Page 8: CQRS: high availability, scabaility, and maintainability](https://reader033.vdocument.in/reader033/viewer/2022061206/548215e9b4af9f21758b459a/html5/thumbnails/8.jpg)
What is Event Sourcing?An Alternate Way to Represent the Data
Cart Created
Item 1 Added
Item 2 Added
Item 1 Removed
Shipping Information
Added
Relational Model
Event Stream
![Page 9: CQRS: high availability, scabaility, and maintainability](https://reader033.vdocument.in/reader033/viewer/2022061206/548215e9b4af9f21758b459a/html5/thumbnails/9.jpg)
CQRS / ES
Presentation
Validation
Commands
Domain Logic
Data persistence
Read thin-layer
<<projection>>
Based on Rob Ashton’s codeofrob.com/entries/cqrs-is-too-complicated.html
![Page 10: CQRS: high availability, scabaility, and maintainability](https://reader033.vdocument.in/reader033/viewer/2022061206/548215e9b4af9f21758b459a/html5/thumbnails/10.jpg)
• Data is sent from Write model to Read model
• Possibility of stale data• Does it have a business impact?
Eventual ConsistencyThe Trade-Off
![Page 11: CQRS: high availability, scabaility, and maintainability](https://reader033.vdocument.in/reader033/viewer/2022061206/548215e9b4af9f21758b459a/html5/thumbnails/11.jpg)
“For the things we have to learn before we can do them, we learn by doing them.”
~Aristotle
![Page 12: CQRS: high availability, scabaility, and maintainability](https://reader033.vdocument.in/reader033/viewer/2022061206/548215e9b4af9f21758b459a/html5/thumbnails/12.jpg)
![Page 13: CQRS: high availability, scabaility, and maintainability](https://reader033.vdocument.in/reader033/viewer/2022061206/548215e9b4af9f21758b459a/html5/thumbnails/13.jpg)
• Is there a natural seam between reads and writes? •Are the business rules ever changing? • Is scalability one of the challenges? •Are benefits that CQRS brings clear?
When to Use CQRS?
![Page 14: CQRS: high availability, scabaility, and maintainability](https://reader033.vdocument.in/reader033/viewer/2022061206/548215e9b4af9f21758b459a/html5/thumbnails/14.jpg)
• Throw away your assumptions•Only distribute when necessary• CQRS is not a top-level architecture• Choose the right approach for each part of the problem • In a message-based system, tracing is very important• Test for performance early and frequently• Existing libraries, framework, and infrastructures can help
Some Lessons Learned
![Page 15: CQRS: high availability, scabaility, and maintainability](https://reader033.vdocument.in/reader033/viewer/2022061206/548215e9b4af9f21758b459a/html5/thumbnails/15.jpg)
Scalability results from Independence
Insights After CQRSUnits of Scale
![Page 16: CQRS: high availability, scabaility, and maintainability](https://reader033.vdocument.in/reader033/viewer/2022061206/548215e9b4af9f21758b459a/html5/thumbnails/16.jpg)
•cqrsjourney.github.com•aka.ms/cqrs•aka.ms/cqrspdf
Resourcesmicrosoft.com/practices
@bennagedev.bennage.com
Русская версия в апреле 2014!