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

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

问题描述

构建微服务架构,我面临着同一微服务实例之间数据共享的问题.

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

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

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使用该实例上的所有DB都使用的临时DB(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.

我计划在Load Balancer后面隐藏多个实例

I plan to hide multiple instances behind Load Balancer

这是适合您的App服务器的设计,因此利用数据库集群也应该是合适的.瞄准完整答案-如果您有很多服务并且想要,您可以考虑 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天全站免登陆