微服务架构中的数据库位置 [英] Database location in Microservices Architecture

查看:309
本文介绍了微服务架构中的数据库位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个整体应用程序,现在我们正在使用容器将其转换为微服务架构.

We have a monolithic application which we are now converting to microservice architecture using containers.

我们的微服务是有状态的(即它们需要从db插入/检索数据).根据微服务架构,每个微服务都应具有自己的数据(在我们的示例中为数据库).

Our microservices are stateful (i.e they need to insert/retrieve data from db). As per microservice architecture, each microservice should have its own data (i.e database in our case).

我的问题是,每个微服务的数据库应该在哪里部署,是否应该在部署微服务的主机中,在部署微服务的容器中?它应该在像azure db之类的单独服务器中?

My question is that where the database of each microservice should be deployed, whether it should be in the same host in which the microservice is deployed, in the same container in which the microservice is deployed or it should be in the separate server like azure db or something?

利弊是什么?每种方法的弊端,根据微服务最佳实践的最佳方法是什么? *

What would be the pros & cons of each approach and what is the best approach according to microservice best practices? *

推荐答案

Martin的回答很好,但我想补充一点,因为您使用的是容器化应用程序,因此应确定地单独部署数据库您的服务容器.原因是您的服务可以(独立地)发展,而无状态服务容器的最大好处之一是,如果您拥有它们的集群,则可以使用滚动更新来更新它们,而不会影响您的应用程序可用性.有状态数据库服务的更新比较困难,但预计更新的频率也会降低(而 cockroachdb 等新技术即将出现). 阅读不错.

Martin's answer is good, but I want to add that because you are using a containerized application you should definitely deploy the database separately from your services containers. The reason being that your services can evolve (independently), and one of the biggest benefits of stateless service containers is that, if you have a cluster of them, you can update them using rolling updates without any impact on your application availability. Updates to the stateful database services are more difficult, but also expected to be less frequent (and new technologies like cockroachdb are on the horizon). Good read.

这篇关于微服务架构中的数据库位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆