CQRS System – Best Way to Scale

Architectureasp.net-mvc-3ccqrswcf

In the previous months I have been asking a lot of questions concerning the architecture of an application I'm working on. Thanks to the answers the architectural design has changed – in fact, it has really been simplified as shown in the following graph:

architecture

Internally I have a two services (NOT WCF!) that follow CQS principles. It means that the query service simply returns database views; while the command service has a full domain model that contains all business logic, and repositories to access the database (no event mechanism or other complex pattern here). Both services use the same database. These services are class libraries, NO WCF services, because they are used only internally so I don't need the overhead of WCF (don't distribute your objects, Martin Fowler's first law).

These internal operations are used by the ASP.NET MVC site and the PartnerService. This PartnerService is a WCF service, which exposes the functionality I would like to be exposed to partners.

If I ever need to scale because of high traffic, I could add web servers and/or migrate parts to a full CQRS system (my contracts are already designed for it).

Does anyone see any problems with this?

One thing I see is that if the query or command service changes, this impacts both the web site and partner service directly, so I have to deploy the changes to both. But I don't know if this is an issue…?

Any feedback is appreciated! Thanks!

Best Answer

I think you are on to a winner here.

You have several options for scaling (from easiest to requires some effort).

  1. Buy a bigger machine.
  2. Run each component on its own server.
  3. Run more servers for each component (except for the Database)
  4. Replicate the database and service the "visitors" queries from the replication.
  5. Partition the database by "member id" and run several separate instances of the database to service that group of members.

If you need to scale any more then you are "facebook" and can afford a rewrite.

Related Topic