codefest 2014. christopher bennage — cqrs journey: scalable, available, and maintainable systems

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

Upload: codefest

Post on 14-May-2015

982 views

Category:

Internet


0 download

TRANSCRIPT

Page 1: CodeFest 2014. Christopher Bennage — CQRS Journey: scalable, available, and maintainable systems

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: CodeFest 2014. Christopher Bennage — CQRS Journey: scalable, available, and maintainable systems
Page 3: CodeFest 2014. Christopher Bennage — CQRS Journey: scalable, available, and maintainable systems

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

New RequirementsArchitecting for Today

Page 4: CodeFest 2014. Christopher Bennage — CQRS Journey: scalable, available, and maintainable systems

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: CodeFest 2014. Christopher Bennage — CQRS Journey: scalable, available, and maintainable systems

N-Tier20th Century Architecture

Domain Logic

Presentation

Persistence

Commands Queries

Page 6: CodeFest 2014. Christopher Bennage — CQRS Journey: scalable, available, and maintainable systems
Page 7: CodeFest 2014. Christopher Bennage — CQRS Journey: scalable, available, and maintainable systems

Applying CQRSSeparate Data Stores

Presentation

Validation

Commands

Domain Logic

Data persistence

Queries (generate DTOs)

Page 8: CodeFest 2014. Christopher Bennage — CQRS Journey: scalable, available, and maintainable systems

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: CodeFest 2014. Christopher Bennage — CQRS Journey: scalable, available, and maintainable systems

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: CodeFest 2014. Christopher Bennage — CQRS Journey: scalable, available, and maintainable systems

• 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: CodeFest 2014. Christopher Bennage — CQRS Journey: scalable, available, and maintainable systems

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

~Aristotle

Page 12: CodeFest 2014. Christopher Bennage — CQRS Journey: scalable, available, and maintainable systems
Page 13: CodeFest 2014. Christopher Bennage — CQRS Journey: scalable, available, and maintainable systems

• 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: CodeFest 2014. Christopher Bennage — CQRS Journey: scalable, available, and maintainable systems

• 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: CodeFest 2014. Christopher Bennage — CQRS Journey: scalable, available, and maintainable systems

Scalability results from Independence

Insights After CQRSUnits of Scale

Page 16: CodeFest 2014. Christopher Bennage — CQRS Journey: scalable, available, and maintainable systems

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

Resourcesmicrosoft.com/practices

@bennagedev.bennage.com

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

Page 17: CodeFest 2014. Christopher Bennage — CQRS Journey: scalable, available, and maintainable systems

Вопросы?

Christopher Bennagepatterns & practicesMicrosoft

[email protected]