Microservices Pattern: Database per Service

Status:: ๐ŸŸฉ
Links:: 30_Knowledge/Microservices @Richardson.2017.TransactionalOutboxPattern

Metadata

Authors:: Richardson, Chris
Title:: Microservices Pattern: Database per Service
Date:: 2017
URL:: http://microservices.io/patterns/data/database-per-service.html
DOI::

Notes & Annotations

Color-coded highlighting system used for annotations

๐Ÿ“‘ Annotations (imported on 2024-03-05#11:00:28)

richardson.2017.databaseservice (pg. 2)

Keep each microserviceโ€™s persistent data private to that service and accessible only via its API. A serviceโ€™s transactions only involve its database.

richardson.2017.databaseservice (pg. 2)

There are a few different ways to keep a serviceโ€™s persistent data private. You do not need to provision a database server for each service. For example, if you are using a relational database then the options are: Private-tables-per-service โ€“ each service owns a set of tables that must only be accessed by that service Schema-per-service โ€“ each service has a database schema thatโ€™s private to that service Database-server-per-service โ€“ each service has itโ€™s own database server.

richardson.2017.databaseservice (pg. 2)

Private-tables-per-service and schema-per-service have the lowest overhead. Using a schema per service is appealing since it makes ownership clearer. Some high throughput services might need their own database server

richardson.2017.databaseservice (pg. 2)

The FTGO application is an example of an application that uses this approach. Each service has database credentials that only grant it access its own (logical) database on a shared MySQL server. For more information, see this blog post.