High Performance Distributed Systems with CQRS

3,191 views

Published on

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,191
On SlideShare
0
From Embeds
0
Number of Embeds
195
Actions
Shares
0
Downloads
56
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

High Performance Distributed Systems with CQRS

  1. 1. High-Performance Distributed Systems withCommand/Query Responsibility Segregation<br />Jonathan Oliver<br />Utah Code Camp 2010<br />
  2. 2. Think Differentlier<br />Best practices != best thinking<br />Blind vs intentional application<br />Question everything<br />How much does it cost?<br />
  3. 3. Domain Muddling and Modeling<br />What was the original intent?<br />Screen-based aggregate roots?<br />Show domain state?<br />Validation?<br />Get/set, go!<br />
  4. 4. Distributed Systems Architecture<br />
  5. 5. Optimistic and Pessimistic Stalemate<br />Collaborative users<br />Current state?<br />Get data<br />Get data<br />Stale data<br />Update data<br />
  6. 6. Layeringitis<br />Why go through all the layers?<br />
  7. 7. Tiers for Fears<br />Why transform across the tiers?<br />DTOs: more code, tests, maintenance, $$$<br />Pre-transformed?<br />
  8. 8. CQRS: Gotta Keep ‘Em Separated<br />SOLID, Architectural “S”<br />
  9. 9. Query Query Quite “Contrery”<br />Showing data<br />Query-only storage<br />KISS, YAGNI<br />If it’s stale anyway<br />List of Customers<br />---------------------<br />---------------------<br />---------------------<br />(from 10 minutes ago)<br />
  10. 10. All Your Database Are Belong To Us<br />Screen-based views<br />UnDRY your data—data duplication<br />“Persistent View Model”<br />Storage/database requirements<br />Scaling out<br />SELECT * FROM Carts WHERE ID = 456;<br />
  11. 11. Queries: Summary<br />Stale data<br />“Persistent View Model”<br />For queries only<br />One table per view<br />Updated by events<br />Data duplication is good<br />No table relationships<br />No foreign keys<br />
  12. 12. Command & Conquer<br />Say what?<br />What is a command?<br />Intention revealing<br />SaveInvoicevsPlaceOrder<br />SaveCustomervsMakeCustomerDelinquent<br />
  13. 13. UI Design<br />Excel-based UIs<br />Task-based UIs<br />
  14. 14. This Time It’s Gonna Be Different<br />Can we fully trust user decisions?<br />
  15. 15. Commands and Validation<br />Validation<br />Is the input potentially good?<br />Ranges, lengths, etc<br />Fail fast<br />Leverage persistent view model<br />Unique emails?<br />Decides if a command should be sent<br />Enables high probability of success<br />
  16. 16. Business Rules<br />Should we do this?<br />Based upon the current system state<br />
  17. 17. Commands: Summary<br />Expresses intent<br />Reply is: “Thank you, we’ve received your input.”<br />Asynchronous<br />Amazon<br />Netflix<br />
  18. 18. Domain Models, Take 2<br />Commands already validated<br />No relationships for reading<br />Only persists what it needs<br />Behavior: Give discounts to high-volume customers<br />
  19. 19. The Big Picture<br />Image courtesy Udi Dahan<br />
  20. 20. The Big Picture: Summary<br />Simple 2-tier queries<br />Commands express intent<br />Task-based UI captures intent<br />Smaller, more focused pieces <br />
  21. 21. Questions?<br />

×