arunsah.github.io

Database architecture in Microservices

📅 2020-06-07 🖊️ @arunsah 🧭 Pune, India


CAP Theorem

Managing inter-service transactions

Data storage and management in Microservice

Database per Service Pattern

Shared database

begin transaction
...
select order_total from order where cid=?;
...
select credit_limit from customer where cid=?;
...
insert into order ...
...
-- db will ensures that credit_limit will not be exceeded even in case of simultaneous transactions for same customer
commit transaction

Saga


API Composition

CQRS


Domain Event

Event sourcing

Axon’s focus is much more on the abstraction of messaging, where messaging is both Commands, Events and (in a later stage also) Queries. It provides annotations to demarcate Event and Command handlers. It also allows you to design your entities in a way that keeps it decoupled from the framework’s internals. This abstraction allows you to “plug in” any database you would like to use as Event Store. Axon provides support for JPA, JDBC and MongoDB out of the box. As far as I can tell, Eventuate provides its own event store implementation. cqrs - Axon Framework vs Eventuate comparison - Stack Overflow

References: