Should a microservice have its own database server "instance" if using the same database type?

Viewed 241

I think a microservice should always have its own database but does it make sense to have that database in a separate server instance as in several SQL Server instances in Kubernetes? Or should microservices share an instance but have separate databases within the instance?

1 Answers

In general, the advice to segregate databases has to do with the autonomy of that service in terms of being able to have a schema that works for that service and similar. So as far as that goes, sharing DBMS instances (e.g. the same SQL Server instance) is absolutely fine: it's roughly in the same category as instances of multiple services being run on the same VM/host in your Kubernetes cluster.

That said, sharing DBMS instances, like any other form of shared infrastructure, does imply some correlation of failures, so you may want to take that into account when you have a choice of which services to share a DBMS with (e.g. if service B will see increased load because service A is down, it's probably not a great idea for them to share much infrastructure).

There's also an argument that when two services happen to have their databases in the same DBMS, this fact increases the chance that eventually someone takes advantage of that fact for short-term gain, but that really depends on how much you trust the teams maintaining the services.

Related