具有共享数据库的微服务?使用多个ORM? [英] Microservices with shared database? using multiple ORM's?

查看:83
本文介绍了具有共享数据库的微服务?使用多个ORM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习微服务,我将用微服务架构来构建一个项目.

I'm learning about microservices and I'm gonna build a project with a microservices architecture.

问题是,我的队友之一希望对所有服务使用一个数据库,共享所有表,以便数据不会重复",每个服务都将使用不同的框架和语言(例如django和rails)构建完全不同的ORM标准.

The thing is, one of my team mates want to use one database for all services, sharing all tables so "data doesn't get repeated", each service would be built with different frameworks and languages like django and rails which use very different ORM standards.

正确的方法是什么?因为我认为使用一个数据库会涉及很多黑客" ORM,以使其正常工作.

What would be the correct approach? Since I think working with one database would involve a lot of "hacking" the ORMs in order to make them work correctly.

推荐答案

如果所有服务共享相同的数据库表,则您不太可能从微服务体系结构中受益.这是因为您正在有效地紧密耦合服务.如果数据库表更改,则所有服务都必须更改.

You are not likely to benefit from a Microservices architecture if all the services share the same database tables. This is because you are effectively tightly coupling the services. If a database table changes all the services will have to change.

您必须了解,微服务体系结构的全部原因是为了减少开发团队之间的依赖性,并允许他们通过快速发布独立地前进.

You have to understand that the whole reason for a Microservices architecture is to reduce dependencies between development teams and allow them to move ahead independently with fast releases.

这是来自Amazon CTO Werner Vogels的报价(亚马逊率先推出了许多微服务风格的架构):

Here is a quote from Werner Vogels, the Amazon CTO (Amazon pioneered a lot of the Microservices style architecture):

对我们来说,面向服务意味着将数据封装为 对数据进行操作的业务逻辑,只有通过 已发布的服务界面.不允许直接数据库访问 来自服务外部,并且 服务.

For us service orientation means encapsulating the data with the business logic that operates on the data, with the only access through a published service interface. No direct database access is allowed from outside the service, and there’s no data sharing among the services.

有关更多信息,请阅读

For more information read this and this.

这篇关于具有共享数据库的微服务?使用多个ORM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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