Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add separate databases for reading and writing. #35

Open
AdamOleszko opened this issue Feb 22, 2021 · 0 comments
Open

Add separate databases for reading and writing. #35

AdamOleszko opened this issue Feb 22, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@AdamOleszko
Copy link

Feature Request

Describe the solution you'd like

Add separate databases for reading and writing.
In the template, both databases can use PostgreSQL (it can be changed in a particular microservice, depending on specific needs).
To do:

  1. Add a new Postgres instance to docker-compose
  2. Create two separate repositories and entities (one for reading and one for writing)
  3. Differ data in these databases (just to show the example)
  4. Keep databases synchronized using events

Teachability, Documentation, Adoption, Migration Strategy

Database for commands should as it is now. The new database for queries should be used for all "GET" operations. In addition, it is important to keep this DB synchronized with the commands database. For this purpose, we need to handle proper events and update this database asynchronously, in the background.

What is the motivation / use case for changing the behavior?

In many cases, we will need to get complicated data from many microservices in a single query. To avoid making "in memory joins" in the API gateway that are inefficient we decided to use CQRS pattern. Separate databases are one of the main points of this pattern. Thanks to that we will store data similar as much as possible to these ones fetched by clients.

@AdamOleszko AdamOleszko added the enhancement New feature or request label Feb 22, 2021
@AdamOleszko AdamOleszko self-assigned this Feb 22, 2021
AdamOleszko added a commit that referenced this issue Mar 13, 2021
AdamOleszko added a commit that referenced this issue Mar 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant