Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Exploring CQRS and Event Sourcing

1,949 views

Published on

A journey into high scalability, availability, and maintainability with Windows Azure

Published in: Technology
  • Be the first to comment

Exploring CQRS and Event Sourcing

  1. 1. Christopher BennageMicrosoft
  2. 2. Exploring CQRS and Event SourcingA journey into high scalability, availability, and maintainability with Windows Azure
  3. 3. Terminology
  4. 4. What is CQRS?Separating Reads from WritesCommandQueryResponsibilitySegregation An architectural pattern that separates Commands, that change state, from Queries that only read state.
  5. 5. Simple Example of CQRSSegregating Queries Presentation Validation Queries (generate DTOs) Commands Domain Logic Data persistence Based on Rob Ashton’s codeofrob.com/entries/cqrs-is-too-complicated.html
  6. 6. Taking it further…Separate Data Stores Presentation Validation Queries (generate DTOs) Commands Domain Logic Data persistence
  7. 7. What is Event Sourcing?An Alternate Way to Represent the Data Relational Model Event Stream Shipping Item 1 Cart Created Item 1 Added Item 2 Added Information Removed Added
  8. 8. CQRS / ES Presentation Validation Read thin-layer Commands Domain Logic Data persistence Based on Rob Ashton’s codeofrob.com/entries/cqrs-is-too-complicated.html
  9. 9. Eventual Consistency The Trade-Off• Asynchronous is faster, but may yield stale data• Write Model can be consistent• Write Model is the source of truth
  10. 10. a CQRS Journey
  11. 11. “For the things we have tolearn before we can do them,we learn by doing them.” ~Aristotle
  12. 12. Project Objectives• Build Consensus• Focus on Learning• Leverage Windows Azure
  13. 13. Decomposing the Domain Conference Discounts Orders & Management Registrations Payments
  14. 14. demo >> conference management system
  15. 15. When to Use CQRS?• Do multiple users compete for access to the same resources?• Are the business rules ever changing?• Is scalability one of the challenges?• Is the business logic complex?• Are benefits that CQRS brings clear?
  16. 16. BenefitsCQRS & Event Sourcing• Integration with other systems / screens• Versioning / Evolution• Team development• Testing• Performance can be fine-tuned separately
  17. 17. Some Lessons Learned• Throw away your assumptions• CQRS space is a little confusing - inconsistency, dissonance• Not a top-level architecture• Not everything needs to be asynchronous, nor message-based• In messaging, tracing matters big time• Test for performance early• Find or build a robust infrastructure that fits your needs• “Sagas” != sagas; Avoid them at first
  18. 18. Questions?
  19. 19. Resourcesmicrosoft.com/practicesProject Personal• cqrsjourney.github.com • @bennage• aka.ms/cqrs • dev.bennage.com• aka.ms/cqrspdf

×