Search code examples
databasedeploymentmicroservices

Deploying microservices and their databases on separate nodes


I have a general question concerning microservice applications and their deployment.

Based on the pattern, due to loose coupling and separation of concerns, that every microservice should have its own database (if needed) is clear. However, can these couples of microservices and databases be separated exclusively and be deployed on separate hardware nodes?

For example, if I use Docker, can I deploy the microservice X and corresponding database X in two different containers residing in two different machines with separate IP-addresses?

It should be possible with the extra afford. However, what makes me curios is actually what would speak for or against such an approach? Would there be any gain by doing it? Or would it be just an over-engineering?


Solution

  • For example, if I use Docker, can I deploy the microservice X and corresponding database X in two different containers residing in two different machines with separate IP-addresses?

    Yes, that's what I would suggest you do, because your microservice and datastore can scale independently and you can set up monitoring, metrics and alerts independently (for the metrics that matter to that service).

    Downside: Well, you will have a bit of network latency, and you will have to maintain two different "machines".

    NOTE: "Two different machines" is arguable, as you may end up in 2 different VMs in the same physical machine unless you go with the bare metal machines in your own data center.