Clustering a DDD/CQRS/ES app
Rickard Öberg <[email protected]>
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <[email protected]> |
Hi, I've been experimenting with a simple app (todo-list manager) where I want to try out CQRS/ES with a REST API on top. You can see the code at: https://github.com/rickardoberg/cqrs (CQRS/ES library) https://github.com/rickardoberg/stuff (todo list app) https://github.com/rickardoberg/shithappens (app consuming Stuff REST API for automation) Yesterday I looked into the question of "how would I cluster this?". The REST API creates commands and dispatches to a command handler that then invokes the domain. So what I did was to introduce a command handler filter that uses Hazelcast to distribute the command with global ordering into set of servers. All servers get the same sequence of commands, process them locally, generate the events, update the views. Tremendously simple, and works. The instance that published the command gets the result and/or exception from the command handler, and uses that to create a REST API response synchronously. If the REST client (e.g. a browser) is pinned to a server using cookies it gets a read-what-you-write guarantee. Awesome. The main remaining issue is how to deal with failures, or bringing up a new server. Don't quite know the best way to handle that yet. But my question is: if anyone else is clustering their CQRS/ES apps, how did you do it? Where did you put in the clustering, and how do you partition and handle failures etc.? /Rickard ------------------------------------