3.13. Microservice Database

  • Polyglot Persistence

  • Database per Service

  • Shared database

  • Database triggers


Figure 3.32. 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


Figure 3.33. 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


Figure 3.34. 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