微服务:每个实例或每个微服务的数据源? [英] Microservices: datasource per instance or per microservice?

查看:38
本文介绍了微服务:每个实例或每个微服务的数据源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

构建微服务架构我遇到了同一个微服务实例之间数据共享的问题.

Building microservice architecture I faced the problem of data sharing between instances of the same microservice.

我有微服务,大量使用它的数据源 - 每个服务请求都会导致数据库请求(通常是插入).该服务将被大量使用,我计划在负载均衡器后面隐藏多个实例.这里提出了一个问题:这些实例应该使用一个数据库(数据库会成为瓶颈吗?)还是多个(每个实例的数据源)有?

I have microservice, that massively uses it's datasource - every request to service cause database request (usually insert). This service will be used very heavily and I plan to hide multiple instances behind Load Balancer. And here rises a question: shall these instances use ONE database (will the database be a bottleneck?) or MULTIPLE (datasource per instance) have?

推荐答案

在我对 mSOA 架构的体验中,我从未见过

In my experience with mSOA architecture, I've never seen

MULTIPLE(每个实例的数据源)

MULTIPLE (datasource per instance)

使用.即使您打算大量加载它,最常见的 DB 本质上也支持多线程访问.通常,DB 系统的瓶颈(或最慢的部分)是磁盘.我们不得不多次扩展我们的集群(如果你在云中相对便宜,但可扩展性也可能成为一个问题,因为需要更多的线程来管理和执行扩展的数据库系统).请记住,某些 RDBMS 使用临时数据库 (tempdb),该实例上的所有数据库都使用该数据库进行排序、散列、临时变量等.多线程和拆分此 tempdb 文件可用于提高 tempdb 的吞吐量,从而提高整体服务器性能.

to be used. Even if you plan to load it heavily, the most common DBs by nature support multi-threading access. Usually the bottleneck (or slowest part) of a DB system is the disk. We had to scale our clusters several times (relatively cheap if you are in the cloud, but scalability can also become an issue, as more threads will be required to manage and execute the scaled DB system). Keep in mind that some RDBMS use a temporary DB (tempdb) that is used by all the DBs on that instance for sorting, hashing, temporary variables, etc. Multithreading and splitting up this tempdb files can be used to improve the throughput of the tempdb, thereby improving overall server performance.

自从我与 Orchard 合作以来,我不得不说有一些极端情况,当您的行为一个实例没有完全(及时)同步.这会导致对资源的访问被拒绝(在注册事件之后),即使在正确的身份验证之后也是如此.

Since now I work with Orchard, I have to say that there are some corner cases, when your actions over one instance are not completely (and timely) synced. This causes access over resources to be denied (right after registration of the event) even after correct authentication.

我打算在负载均衡器后面隐藏多个实例

I plan to hide multiple instances behind Load Balancer

这是您的应用服务器的正确设计,因此使用数据库集群也应该是合适的.针对完整答案 - 您可以考虑 DWH,以防您有很多服务并且想要能够从他们所有的数据库中进行一些数据挖掘和分析.

This is a proper design for your App servers, so utilizing a DB cluster should be suitable as well. Aiming at full answer - you can consider DWH, in case you have a lot of services and you want to be able to do some data mining and analysis from all their DBs.

这篇关于微服务:每个实例或每个微服务的数据源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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