Scaling database in a microservice architecture

二次信任 提交于 2020-01-02 08:56:52

问题


Lets say we have 5 microservices (μS) and each microservice requires one database with a few tables. Each of these services needs to be able to scale including the database queries. To do that we have a few options that I know of:

1. 1-μS; 1 instance; 1 DB instance

Don't scale horizontally, just vertically.

2. 1-μS; N instances; 1 DB instance

Every instance of a service gets to read and write to the same database. Simple way to scale if the service processing is the bottleneck.

3. 1-μS; N instances; HA DB cluster

Every instance of a service gets to read and write to the same HA database. Good way to scale if the database read/write is also a bottleneck. Greater operation cost.

4. N-μS; N instances; HA DB cluster

Every instance of every service gets to read and write to the same HA database cluster. Each service uses its own database in the HA DB cluster.

5. Other

Are there other ways to scale a database alongside the service that requires it?


With each solution there are trade-offs, whether it be read or write performance, operation cost etc., but what would be recommended solution for scaling database:

  • with service and database being equal in a way that scaling a service required scaling the database ?
  • with service requiring more processing time meaning that the service needs to scale and not the database ?
  • with database requiring more processing time than the service ?

My opinion is that if a servise is high on writes then 3 or 4 is a solution and for the rest 4 is a solution.

来源:https://stackoverflow.com/questions/54705313/scaling-database-in-a-microservice-architecture

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!