cqrs: high availability, scabaility, and maintainability

17
Exploring CQRS and Event Sourcing A journey into high scalability, availability, and maintainability with Azure Christopher Bennage patterns & practices microsoft.com/practices

Upload: christopher-bennage

Post on 06-Dec-2014

1.093 views

Category:

Software


5 download

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

Exploring CQRS and Event SourcingA journey into high scalability, availability, and maintainability with AzureChristopher Bennagepatterns & practicesmicrosoft.com/practices

Grigori Melnik (PATTERNS & PRACTICES)
I would add our group's web address:microsoft.com/practices
Page 2: CQRS: high availability, scabaility, and maintainability
Page 3: CQRS: high availability, scabaility, and maintainability

•Scale with predictable cost•Scale at unpredictable times•Be continuously available

New RequirementsArchitecting for Today

Page 4: CQRS: high availability, scabaility, and maintainability

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

N-Tier20th Century Architecture

Domain Logic

Presentation

Persistence

Commands Queries

Page 6: CQRS: high availability, scabaility, and maintainability
Page 7: CQRS: high availability, scabaility, and maintainability

Applying CQRSSeparate Data Stores

Presentation

Validation

Commands

Domain Logic

Data persistence

Queries (generate DTOs)

Page 8: CQRS: high availability, scabaility, and maintainability

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

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

• 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

“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
Page 13: CQRS: high availability, scabaility, and maintainability

• 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

• 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

Scalability results from Independence

Insights After CQRSUnits of Scale

Page 16: CQRS: high availability, scabaility, and maintainability

•cqrsjourney.github.com•aka.ms/cqrs•aka.ms/cqrspdf

Resourcesmicrosoft.com/practices

@bennagedev.bennage.com

Русская версия в апреле 2014!

Page 17: CQRS: high availability, scabaility, and maintainability

Вопросы?

Christopher Bennagepatterns & practicesMicrosoft

[email protected]