190 likes | 334 Views
Let’s Learn Together. Intro to CQRS. Ted M. Young @jitterted Developer & Agile Coach Guidewire Software, San Mateo, CA. Silicon Valley Code Camp – October 9, 2011. Creative Commons Attribution- ShareAlike ( CC BY-SA 3.0 ). What’s the Problem. CAP Consistency Availability
E N D
Let’s Learn Together Intro to CQRS Ted M. Young @jitterted Developer & Agile Coach Guidewire Software, San Mateo, CA Silicon Valley Code Camp – October 9, 2011 Creative Commons Attribution-ShareAlike (CC BY-SA 3.0)
What’s the Problem • CAP • Consistency • Availability • Partitionability
Can’t Have All Three • CAP: Choose Two • Consistency + Availability • Sacrifice Partitionability • E.g., single database, clustered database • Consistency + Partitionability • Sacrifice Availability • E.g., pessimistic locking, distributed locking • Availability + Partitionability • Sacrifice Consistency • E.g., optimistic locking, merging, expirations • Many systems are like this: eventually consistent • Whether you like it or not
BASE vs. ACID • Basically Available • Soft-state • Eventual consistency • Stale data is OK
What’s so bad about Eventual Consistency
BASE is Not New Inktomi Presentation in 1998
BASE vs. ACID Not an either-or, but a spectrum
CQRS Leans to BASE
CQRS is Command Query Responsibility Segregation
Command Mutator
Re-think UI Stop The Forms No more CRUD?
Query Read-Only With respect to the queried data
Resources: CAP, Other Background • Bertrand Meyer • Command-Query Separation, §23.1 (p. 751) • Object-Oriented Software Construction, 2nd Ed. (ISBN 0136291554) • Dr. Eric Brewer, Inktomi • Presentation (1998) • http://www09.sigmod.org/disc/disc99/disc/nsf_acad_ind/brewer/sld019.htm • Dan Pritchett • BASE and latency • http://www.infoq.com/articles/pritchett-latency • Prevayler • http://prevayler.org/old_wiki/Welcome.html
Resources: CQRS-Specific • Greg Young (no relation) • CQRS and CAP • http://codebetter.com/gregyoung/2010/02/20/cqrs-and-cap-theorem/ • UdiDahan • Good overview • http://www.udidahan.com/2009/12/09/clarified-cqrs/ • Martin Fowler’s CQRS • http://martinfowler.com/bliki/CQRS.html • Axon Framework (Java) • http://www.axonframework.org
Resources: CQRS-Specific • RinatAbdullin • CQRS Starting Page • http://abdullin.com/cqrs/ • More useful info from Rinat with good PDF diagram • http://abdullin.com/xlim/ • PålFossmo • Another nice blog entry on CQRS • http://blog.fossmo.net/post/Command-and-Query-Responsibility-Segregation-%28CQRS%29.aspx
Thanks! Final Questions? Follow me on Twitter: @jitterted Email me: tyoung@guidewire.com [Guidewire is hiring devs and testers!]