Database per Service

Problem Statement

Microservice architecture structures an application as a set of loosely coupled microservices and each service can be developed independently in agile manner to enable continous delivery/deployment. What should be the database structure/architecture in microservices based application.


We can keep each microservice data private to that microservice and this data will be accessible only via relevant microservice. The microservice will use its own database for transactions. Following diagram shows database per service design pattern implementation.

Database per Service Microservices Design Pattern

Database per Service does not always need to have seperate databases provisioned. We can implement the pattern using following ways considering a relational database.

  • Private tables per Service − Each microservice can utilize a set of tables and these tables should be accessible only via their relevant microservice.

  • Schema per Service − A seperate schema can be defined per microservice.

  • Database Server per Service − Entire database server can be configured per microservice.

Kickstart Your Career

Get certified by completing the course

Get Started