3.13. Microservice Database

  • Polyglot Persistence

  • Database per Service

  • Shared database

  • Database triggers

../../_images/microservices-database-compare.png

Figure 3.54. Difference b/w Monolith and MicroService Architectures 1

3.13.1. Polyglot Persistence

  • overhead związany z wielością usług

  • nowe technologie

  • różne działające równoległe wersje np. baz danych

  • Deprecation policy

  • Problem z backupem danych

3.13.2. Database per Service

  • Keep each microservice's persistent data private to that service and accessible only via its API.

  • Wiele baz danych w jednej usłudze

  • Mieszane, usługi mają jedną bazę danych

../../_images/microservices-database-per-service.png

Figure 3.55. Database per Service

3.13.3. Shared database

  • Use a (single) database that is shared by multiple services. Each service freely accesses data owned by other services using local ACID transactions

../../_images/microservices-database-shared.png

Figure 3.56. Shared database

3.13.4. Database triggers

  • Reliably publish events whenever state changes by using database triggers. Each trigger inserts an event into an EVENTS table, which is polled by a separate process that publishes the events.

  • Czy są ok?

  • Czym się różni struct od Class

3.13.5. References

1

ul Haq, S. Introduction to Monolithic Architecture and MicroServices Architecture. Year: 2018. Retrieved: 2022-03-28. URL: https://medium.com/koderlabs/introduction-to-monolithic-architecture-and-microservices-architecture-b211a5955c63