简体   繁体   English

什么时候不应该使用微服务?

[英]When we should not to use microservices?

In which scenario, we should not use micro services architecture? 在哪种情况下,我们不应该使用微服务架构? So far I can see the design for micro services, looks good for many use cases. 到目前为止,我可以看到微服务的设计,看起来很好用于许多用例。

One of the basic use case I will not recommend for POC (Proof of concepts) projects. 我不会推荐POC(概念证明)项目的基本用例之一。

This is a very broad, and possibly, very opinionated question. 这是一个非常广泛的,可能是非常自以为是的问题。 I would not advocate the use of micro services when you have a single application with many shared dependencies that is generally always deployed as a unit. 当您拥有一个通常始终作为一个单元部署的许多共享依赖项的应用程序时,我不会提倡使用微服务。

Micro services are great, and they have their place - but if your application is of a such a nature that it's always deployed as a unit, micro services can seriously expand complexity - now you're deploying a multitude of separate artifacts, all at once, instead of just a single application. 微服务很棒,而且它们有自己的位置 - 但如果你的应用程序具有这样的性质,它总是作为一个单元部署,微服务可以严重扩展复杂性 - 现在你正在部署大量单独的工件,一次性而不只是一个应用程序。 The example that comes to mind for me is an ERP system. 我想到的例子是ERP系统。

Edit: And to expand on this, micro services shouldn't be your default architecture for an application. 编辑:为了扩展这一点,微服务不应该是应用程序的默认架构。 Keep it as simple as possible, and if you run into scalability issues, or something else that justifies going the micro services route, then do it. 保持尽可能简单,如果遇到可扩展性问题,或其他证明微服务路由合理的事情,那就去做吧。 Keep it as simple as it can possibly be. 保持尽可能简单。 So, IMHO, the answer to "when should I not use micro services?" 那么,恕我直言,答案是“什么时候不应该使用微服务?” is "when you don't need them". 是“当你不需要它们时”。

See YAGNI . YAGNI

In which scenario, we should not use micro services architecture? 在哪种情况下,我们不应该使用微服务架构?

You don't have to apply the microservices architectural style for scenarios that do not come with the problems that the style tries to solve. 您不必将微服务架构样式应用于没有样式试图解决的问题的场景。 So which problems are those? 那些问题是哪些?

Before giving the answer - Microservices is a buzz word and describes an architectural style that tries to answer the age-old question of "how to break an application into logical components". 在给出答案之前 - 微服务是一个流行词,描述了一种建筑风格,它试图回答“如何将应用程序分解为逻辑组件”这一古老的问题。 While there is no exact definition, it usually comes down to independently develop-able and deploy-able components with a specific domain purpose. 虽然没有确切的定义,但它通常归结为具有特定域目的的独立开发和可部署组件。 So with that in mind - Here are the problems that the microservices architectural style tries to solve: 所以考虑到这一点 - 以下是微服务架构风格试图解决的问题:

  1. The most important problem is scaling development in large organizations. 最重要的问题是扩大大型组织的发展。 Microservices allow independent teams to move fast with independent release cycles. 微服务允许独立团队在独立的发布周期内快速移动。 Compare that with a large "monolith" that has to aggregate all dependencies and can spit out a release every couple months at best. 将其与一个必须聚合所有依赖关系的大型“整体”进行比较,并且每隔几个月最多可以发布一个版本。 So whenever a company is trying to organize hundreds of developers to develop a large server based application they should probably look into setting up teams being responsible for microservices. 因此,每当一家公司试图组织数百名开发人员开发基于大型服务器的应用程序时,他们应该考虑设置负责微服务的团队。 This is because "Architecture follows Organization" ( Conway's law ). 这是因为“建筑遵循组织”( 康威定律 )。

  2. Scalability of the application itself. 应用程序本身的可伸缩性。 In conjunction with a stateless design the services can be deployed at scale in a clustered fashion. 与无状态设计相结合,可以以集群方式大规模部署服务。 So whenever the user base is supposed to be growing over time you will most likely benefit from a microservices architectural style. 因此,每当用户群随着时间的推移而增长时,您很可能会从微服务架构风格中受益。

  3. Enforce separation of concerns. 强制分离关注点。 In a "monolithic" development it is common to minimize persistent data schemas and have many components use the same database persistence. 在“单片”开发中,通常最小化持久数据模式并使许多组件使用相同的数据库持久性。 This increases complexity by adding indirect dependencies and thus adds to the communication and organizational overhead of releasing new software versions. 这通过添加间接依赖性来增加复杂性,从而增加了发布新软件版本的通信和组织开销。 Microservices are not allowed to share data persistency so this issue can be avoided. 不允许微服务共享数据持久性,因此可以避免此问题。

  4. Communication issues. 沟通问题。 If the communication between components is not well defined, the effort for reusing components increases drastically. 如果组件之间的通信没有很好地定义,则重用组件的工作量会急剧增加。 Especially over the lifecycle of multiple versions of a component. 特别是在组件的多个版本的生命周期中。 Thus the microservices architectural style has a strong focus on well defined interfaces to the outside world. 因此,微服务架构风格强烈关注与外界明确定义的界面。 This includes the definition of interface versions (Major/Minor) for downstream consumers. 这包括下游消费者的界面版本(主要/次要)的定义。

Then about your conclusion: 然后关于你的结论:

One of the basic use case I will not recommend for POC (Proof of concepts) projects. 我不会推荐POC(概念证明)项目的基本用例之一。

Based on the above points your statement does not necessarily hold true. 基于以上几点,您的陈述不一定适用。 If it is a POC development with a large team and you anticipate any of the mentioned problems you will still benefit from the microservices architectural style. 如果它是一个拥有庞大团队的POC开发,并且您预计会遇到任何上述问题,您仍将从微服务架构风格中受益。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我们什么时候应该在Spring中使用@Component? - When should we use @Component in Spring? 我想解释一下我们可以在哪里使用微服务而不是容器以及它的一些应用程序 - I want explanation on where we can use microservices instead of containers and some applications of it 我们可以使用哪种微服务体系结构来挖掘使用无SQL DB的庞大的整体应用程序? - Which Microservices architecture can we use to drill down a huge monolithic application that uses a no SQL DB? 我们应该在 DDD 中使用“按功能打包”结构吗? - Should we use 'package by feature' structure with DDD? 在微服务中,我应该使用pub / sub而不是RPC来获得更松散的耦合体系结构吗? - In microservices should i use pub/sub instead RPC to get more loosely couple architecture? 前端还是后端应该调用微服务? - Should frontend or backend call microservices? 不同的微服务永远不应该耦合? - Different microservices should NEVER be coupled? 我应该在多个微服务之间共享模型吗? - Should I share models across multiple microservices? 我们应该在服务器和客户端上使用相同的业务类吗? - Should we use the same business classes on server and client? 我们是否应该使用相同的绑定来加载和检索数据? - Should we use same bindings for loading and for retrieving data?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM