I have one confusing point over CQRS(Command and Query Responsibility Segregation)
pattern.
As we know, in CQRS
the read and write operations should happen on separated databases. And in the application level, we need to sync data to read database when write operation happens. For example, the following diagram shows the CQRS pattern which writes data to sqlite
and sync the data based on rabbitmq
to mongodb as read database. (The basic example shown here is based on this article talking about CQRS)
And we also know, the database in production run as a cluster consists of a replica set
which can provide the high availability feature. In the replica set, the primary
server receives write(and read) operations and sync data to the secondary
server(which can response read request). The cluster does a lot of complex works(like election algorithm) to maintain the consistency among the replica set.
My confusing point is if we use CQRS
pattern in the application level, we have separated database for read and write. The database here is a standalone server or a cluster(which contains read/write server inside).
This question doesn't provide sample code, it's more like an architecture level question.