CQRS: high availability, scabaility, and maintainability

Post on 06-Dec-2014

1.093 views 5 download

Tags:

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

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

New RequirementsArchitecting for Today

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

N-Tier20th Century Architecture

Domain Logic

Presentation

Persistence

Commands Queries

Applying CQRSSeparate Data Stores

Presentation

Validation

Commands

Domain Logic

Data persistence

Queries (generate DTOs)

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

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

• Data is sent from Write model to Read model

• Possibility of stale data• Does it have a business impact?

Eventual ConsistencyThe Trade-Off

“For the things we have to learn before we can do them, we learn by doing them.”

~Aristotle

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

• 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

Scalability results from Independence

Insights After CQRSUnits of Scale

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

Resourcesmicrosoft.com/practices

@bennagedev.bennage.com

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

Вопросы?

Christopher Bennagepatterns & practicesMicrosoft

christopher.bennage@microsoft.com