Managing data-store concurrency as microservices scale

半城伤御伤魂 提交于 2019-12-11 02:06:18

问题


I am still trying to find my way around micro-services. I have a fundamental question.

In an enterprise scenario, micro-services would probably have to write to a persistent data-store - be it a RDBMS or some kind of NoSQL. In most cases the persistent data-store is enterprise grade, but a single entity (ofcourse replicated and backed up).

Now, let's consider the case of a single micro-service deployed to private/public cloud environment having it's own persistent data-store (say enterprise grade RDBMS). As I scale my micro-service, there will be multiple instances of the micro-service trying to read/write from the same data-store. A traditional data-store can probably be tuned to handle ~50-200 concurrent connections. How do I handle a situation when my microservices has to be scaled much beyond that?

What are the best practices in such a scenario? Any patterns that can be used?


回答1:


Ideally each microservice instance is self-contained so that each instance can scale independently of others while also encapsulating its state so that others can only access it through a well-defined API. So not only do you need to figure out how to scale your database(s) that your microservices use to store state, you also have this encapsulation problem to solve if you really want to nail this architectural pattern.

Have you looked at Service Fabric to solve this? Service Fabric has a concept of stateful services where data is actually stored inside each microservice instance. The platform handles replication and disk persistence automatically for HA and also has data partitioning built-in for distribution across machines. The idea is basically to ditch the central database, instead co-locating your compute and data within a microservice instance. Now your services are self-contained and suddenly the solution fits this architectural pattern nicely, because now each microservice instance can be scaled out and upgraded independently and you have full encapsulation of your data inside the service. The trade-off of course is that you don't get the feature set of a full-blown RDBMS, but if you're considering NoSQL stores anyway that shouldn't be a huge deal.

My thought on this has always been that a central store like a database is somewhat of an anti-pattern in a shared-nothing microservices architecture. Full disclosure though: I work on Service Fabric so my opinion may be a little biased!



来源:https://stackoverflow.com/questions/36948775/managing-data-store-concurrency-as-microservices-scale

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!