Tuesday, May 28, 2013

CQRS Experience 01

Did you hear about CQRS? Are you using it?

We, at Selise, are building a large enterprise application with CQRS. I would like to share some of my experience with it.

I would take a moment to explain it first in really basic words, you can checkout and dig more later. The core principle is  CQS - Command Query Separation which tells you to separate your data read and data write operations. The method returns data should not modify the data, on the other hand the method that modifies the data (like inserting, updating or deleting) should not return any data. Which means your AddNew Method cannot return the newly added row ID back to you. CQRS ( Command Query Responsibility Segregation or Separation)  is an application CQS concept. We can call it a pattern. Its not an architecture or framework. 

To go a bit deeper with CQRS lets agree to some arguments.

 Argument 1: In any large user base application you will have more read than writes. 

 Argument 2: Reading data to display in the UI from a normalized database is slower than a denormalized database. Joining and retrieving data is expensive, its much faster if you could retrieve all your UI data for a single page as a collection row from a single table of the database without joins. The structure of this table should be more like the View-Model of your application.  

 Argument 3: When user modifies a data, it is not always necessary to synchronously update the database. We can live with some delay and let the database change happen asynchronously. Update of the UI also could be asynchronous. For example while adding a new row to a grid, the UI to add item could make an async request to server to add the row and UI can get back to grid. The grid seems to be not showing the row which just now has been added but the UI is responsive, you can make another add row or click on a different link meanwhile.  If you are still at the grid, after a few sec the row appears. 

Asynchronous database operation

On the next episode we will see how this arguments will drive us to CQRS.

[Read more:Wikipedia - Command–query separation, Martin Fowler on CQRS, Udi Dahan - Clarified CQRS, Greg Young's Blog on CQRS]

11 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. This comment has been removed by a blog administrator.

    ReplyDelete
  6. Nice Blog!! Thanks For Sharing!!!Wonderful blog & good post. Its really helpful for me, waiting for a more new post. Keep Blogging!
    Servicenow Training In Hyderabad

    ReplyDelete
  7. I like reading through a post that will make people think. Also, thank you for permitting me to comment.
    servicenow training and placement in hyderabad

    ReplyDelete
  8. Extremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one. Continue posting
    ServiceNow Training in Chennai

    ReplyDelete
  9. Mummys Gold Casino & Hotel - Jackson County - JTHub
    Experience the best casino 세종특별자치 출장샵 in Kansas City! JT-Mobile and The 동두천 출장샵 Mummys 룰렛 게임 Gold 파주 출장마사지 Casino Hotel offer the most exciting casino 충청남도 출장마사지 experience around in Mississippi

    ReplyDelete
  10. Our team has to spend hours poring by way of every aspect of each web site to get what does and does not work, as these would inform how 더킹카지노 we rate every site. There are nice deal of} mouth-watering bonuses ready for you once you enroll on Wild Casino. But for now, it will do to rest assured that Wild Casino is 100 percent legit. We notably favored BitStarz’s bonuses since you don’t have to opt-in to benefit of|benefit from|reap the benefits of} them. Maybe the bonuses could possibly be} bigger, but they're extra spread out than you’d find on other sites, which, we consider, makes up for the scale of the bonuses.

    ReplyDelete
  11. We charge you a small commission on the profit of your sports trade. Additionally, the platform is constructed to offer a extra “dynamic” trading expertise, similar to trading shares or crypto. Sporttrade is an trade similar to the inventory trade, but as 빅카지노 a substitute of shares we list sporting events. This permits users to “trade” on sports in the same means they trade shares in the monetary market - shopping for and promoting outcomes of sporting events.

    ReplyDelete