high performance distributed systems with cqrs

Post on 07-Dec-2014

3.173 Views

Category:

Documents

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

High-Performance Distributed Systems with

Command/Query Responsibility Segregation

Jonathan Oliver Utah Code Camp 2010

Think Differentlier

Best practices != best thinking Blind vs intentional application Question everything How much does it cost?

Domain Muddling and Modeling

What was the original intent? Screen-based aggregate roots? Show domain state? Validation? Get/set, go!

Distributed Systems Architecture

Optimistic and Pessimistic Stalemate

Collaborative users Current state?

Get data Get data

Update data

Stale data

Layeringitis

Why go through all the layers?

Tiers for Fears

Why transform across the tiers? DTOs: more code, tests,

maintenance, $$$ Pre-transformed?

CQRS: Gotta Keep ‘Em Separated

SOLID, Architectural “S”

Query Query Quite “Contrery”

Showing data Query-only storage KISS, YAGNI If it’s stale anyway

List of Customers---------------------------------------------------------------

(from 10 minutes ago)

All Your Database Are Belong To Us

Screen-based views UnDRY your data—data duplication “Persistent View Model” Storage/database requirements Scaling out

SELECT * FROM Carts WHERE ID = 456;

Queries: Summary

Stale data “Persistent View Model” For queries only One table per view Updated by events Data duplication is good No table relationships No foreign keys

Command & Conquer

Say what? What is a command? Intention revealing

SaveInvoice vs PlaceOrder SaveCustomer vs

MakeCustomerDelinquent

UI Design

Excel-based UIs Task-based UIs

Name Address Phone

Bob 1234 Main St q

Jenny q 867-5309

IT Crowd London, England

0118999 88199 9119725 3

This Time It’s Gonna Be Different

Can we fully trust user decisions?

Commands and Validation Validation

Is the input potentially good? Ranges, lengths, etc

Fail fast Leverage persistent view model Unique emails? Decides if a command should be sent Enables high probability of success

Business Rules

Should we do this? Based upon the current system state

Commands: Summary

Expresses intent Reply is: “Thank you, we’ve received

your input.” Asynchronous Amazon Netflix

Domain Models, Take 2

Commands already validated No relationships for reading Only persists what it needs Behavior: Give discounts to high-

volume customers

The Big Picture

Image courtesy Udi Dahan

The Big Picture: Summary

Simple 2-tier queries Commands express intent Task-based UI captures intent Smaller, more focused pieces

Questions?

top related