[英]Understanding Microservice Architecture
Since I am trying hard to understand the microservice architecture pattern for some work, I came across the following question: 由于我正在努力理解微服务架构模式的某些工作,因此遇到了以下问题:
It's always said that a microservice usually has its own database. 人们总是说微服务通常有自己的数据库。 But does this mean that it always has to be on the same server or container (for example having one docker container that runs a MongoDB and my JAR)? 但这是否意味着它总是必须位于同一服务器或容器上(例如,拥有一个运行MongoDB和我的JAR的docker容器)? Or can this also mean that on one server my JAR is running while my MongoDB is located somewhere else (so two containers for example)? 还是这还意味着在MongoDB位于其他位置(例如两个容器)的同时,我的JAR在一台服务器上运行?
If the first one is correct (JAR and database within one container), how can I prevent that after some changes regarding my application and after a new deployment of my JAR my data of the MongoDB is resetted (since a whole new container is now running)? 如果第一个是正确的( 一个容器中的JAR 和数据库),那么在对应用程序进行一些更改之后以及在重新部署我的JAR之后,如何防止MongoDB的数据重置(因为现在正在运行一个新的容器),我该如何防止)?
Thanks a lot already :-) 非常感谢:-)
Alternative opinion: 替代意见:
First of all each Microservice should have its own database. 首先,每个微服务都应该有自己的数据库。
Secondly it's not necessary and also not recommended to have the Microservice and its database on the same container. 其次,没有必要也不建议将微服务及其数据库放在同一容器中。
Generally a single Microservice will have multiple deployments for scaling and they all connect to a single Database instance which should be a diff. 通常,单个微服务将具有用于扩展的多个部署,并且它们都连接到应为差异的单个数据库实例。 container and if using things like NoSql DB's its a database cluster. 容器,如果使用NoSql DB之类的东西,它就是数据库集群。
Yes, Each Microservice should have its own database and if any other Microservice needs data owned by another microservice, then they do it using an API exposed by Microservices. 是的,每个微服务都应该有自己的数据库,如果任何其他微服务需要另一个微服务拥有的数据,那么它们将使用微服务公开的API来进行处理。 No, it's not at all necessary to have the Microservice and its database to be hosted on the same server. 不,完全不必将微服务及其数据库托管在同一服务器上。 For Example - A Microservice can be hosted on-premise and its database can live in the cloud like AWS DynamoDB or RDS. 例如-微服务可以托管在内部,其数据库可以存在于AWS DynamoDB或RDS之类的云中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.