2.13. Microservice Database

  • Polyglot Persistence

  • Database per Service

  • Shared database

  • Database triggers

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

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

2.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

2.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 2.18. Database per Service

2.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 2.19. Shared database

2.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

2.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