soa-versus-microservices

soa-versus-microservices

SOA versus microservices: What’s the difference?

If you work in IT, you might have heard the SOA versus microservices debate. After all, everyone is talking about microservices and agile applications these days.

如果您从事IT工作,您可能听说过SOA与微服务之间的争论。毕竟,现在每个人都在谈论微服务和敏捷应用程序。

At first glance, the two approaches sound very similar. In some ways, they are. Both are different from a traditional, monolithic architecture in that every service will have its own responsibility. Both benefit from a certain level of decoupling.

乍一看,这两种方法听起来非常相似。在某些方面,它们确实是。两者都不同于传统的单体架构,因为每个服务都有自己的职责。两者都受益于某种程度上的解耦。

The main distinction comes down to scope. To put it simply, service-oriented architecture (SOA) has an enterprise scope, while the microservices architecture has an application scope.

主要区别在于范围。简单地说,面向服务的体系结构(SOA)具有企业范围,而微服务体系结构具有应用程序范围。

Here are some very basic definitions of each with that difference in mind:

这里有一些非常基本的定义,将定义的区别牢记在心:

  • SOA is an enterprise-wide initiative to create reusable, synchronously available services and APIs. This helps developers create applications more quickly and more easily incorporate data from other systems.

SOA是企业范围内创建可重用的、同步可用的服务和api的活动。这有助于开发人员更快地创建应用程序,更容易地合并来自其他系统的数据。

  • Microservices architecture is an option for building an individual application in a way that makes that application more agile, scalable and resilient.

微服务体系结构是构建单个应用程序的一种选择,可以使应用程序更加敏捷、可伸缩和弹性。

soa-versus-microservices-1

Why this difference matters

Many of the core principles of each approach become incompatible when you neglect this difference. If you accept the difference in scope, you may quickly realize that the two can potentially complement each other rather than compete.

当您忽略这种差异时,每种方法的许多核心原则都变得不兼容。如果您接受范围上的差异,您可能很快就会意识到这两者可能是互补的,而不是竞争的。

  • Reuse. In SOA, reuse of integrations is the primary goal and at an enterprise level, striving for some level of reuse is essential. In microservices architecture, creating a microservices component that is reused at runtime throughout an application results in dependencies that reduce agility and resilience. Microservices components generally prefer to reuse code by copy and accept data duplication to help improve decoupling.

重用。在SOA中,集成的重用是主要目标,在企业级别,争取某种级别的重用是必要的。在微服务体系结构中,创建在整个应用程序运行时重用的微服务组件会导致依赖关系,它们会降低敏捷和弹性。微服务组件通常更喜欢通过复制和接受数据复制来重用代码,以帮助改进解耦。

  • Synchronous calls.

  • Data duplication. A clear aim of providing services in an SOA is for all applications to synchronously get hold of and make changes to data directly at its primary source, which reduces the need to maintain complex data synchronization patterns. In microservices applications, each microservice ideally has local access to all the data it needs to ensure its independence from other microservices, and indeed from other applications, even if this means some duplication of data in other systems. Of course, this duplication adds complexity, so it must be balanced against the gains in agility and performance, but this is accepted as a reality of microservices design.

数据重复。在SOA中提供服务的一个明确目标是让所有应用程序同步地获取数据并直接在其主要源上对数据进行更改,从而减少了维护复杂数据同步模式的需要。在微服务应用程序中,每个微服务都理想地具有对其所需的所有数据的本地访问权,以确保其独立于其他微服务,甚至独立于其他应用程序,即使这意味着在其他系统中存在一些数据复制。当然,这种重复增加了复杂性,因此必须在敏捷性和性能方面的收益之间进行平衡,但这已被接受为微服务设计的现实。

Microservices vs. SOA – Is There Any Difference at All?

Lately, there has been a lot of fuss about the differences between these two types of architectures, or whether there is any difference at all. In order to delve deeper into this question that raised hundreds of debates, I will first briefly define both SOA and microservices architecture and their origins, and then we’ll compare them and see how we can best distinguish them.

Service-Oriented Architecture (SOA)

Service Oriented Architecture is a software architecture where distinct components of the application provide services to other components via a communications protocol over a network. The communication can involve either simple data passing, or two or more services coordinating connecting services to each other. These distinct services carry out some small functions such as validating payment, creating a user account, or providing social log-in.

SOA是一种软件架构,应用中不同的组件会通过网络通信协议的方式向其他组件提供服务。通信可以包括简单的数据传递,也可以包括两个或多个协调连接服务的服务。这些不同的服务执行一些小功能,比如验证支付、创建用户帐户或提供社会登录。

Service Oriented Architecture is less about how to modularize an application, and more about how to compose an application by integration of distributed, separately-maintained and deployed software components. It is enabled by technologies and standards that make it easier for components to communicate and cooperate over a network, especially an IP network.

面向服务的体系结构不是关于如何模块化应用程序,而是关于如何通过集成分布式、独立维护和部署的软件组件来组合应用程序。它是由技术和标准支持的,这些技术和标准使组件更容易在网络上通信和合作,特别是IP网络。

There are two main roles in SOA: a service provider, and a service consumer. A software agent may play both roles. The Consumer Layer is the point where users (human, other components of the app, or third parties) interact with the SOA, and the Provider Layer consists of all the services within the SOA.

SOA中有两个主要角色:服务提供者和服务使用者。软件代理可以同时扮演这两种角色。消费者层是用户(人员、应用程序的其他组件或第三方)与SOA交互的地方,提供者层由SOA中的所有服务组成。

soa-versus-microservices-2

Microservices

Microservices, in a way, are the next step in the evolution of Service Oriented Architectures. Basically, this architecture type is a particular way of developing software, web, or mobile applications as suites of independent services – a.k.a microservices. These services are created to serve only one specific business function, such as User Management, User Roles, E-commerce Cart, Search Engine, Social Media Logins, etc. Furthermore, they are completely independent of each other, meaning they can be written in different programming languages and use different databases. Centralized services management is almost non-existent and the microservices use lightweight HTTP, REST, or Thrift APIs for communicating among themselves.

在某种程度上,微服务是面向服务体系结构发展的下一步。基本上,这种体系结构类型是开发软件的一种特殊方式、web或移动应用程序作为独立服务套件。microservices。创建这些服务只是为了服务于一个特定的业务功能,例如用户管理、用户角色、电子商务购物车、搜索引擎、社交媒体登录等。此外,它们彼此完全独立,这意味着它们可以用不同的编程语言编写,并使用不同的数据库。集中式服务管理几乎不存在,而微服务使用轻量级HTTP、REST或Thrift api进行内部通信。

So, Where’s the Difference?

SERVICE-ORIENTED ARCHITECTURE MICROSERVICES ARCHITECTURE
Maximizes application service reusability Focused on decoupling
A systematic change requires modifying the monolith A systematic change is to create a new service
DevOps and Continuous Delivery are becoming popular, but are not mainstream Strong focus on DevOps and Continuous Delivery
Focused on business functionality reuse More importance on the concept of “bounded context”
For communication it uses Enterprise Service Bus (ESB) For communication uses less elaborate and simple messaging systems
Supports multiple message protocols Uses lightweight protocols such as HTTP, REST or Thrift APIs
Use of a common platform for all services deployed to it Application Servers are not really used, it’s common to use cloud platforms
Use of containers (such as Docker) is less popular Containers work very well with microservices
SOA services share the data storage Each microservice can have an independent data storage
Common governance and standards Relaxed governance, with greater focus on teams collaboration and freedom of choice
SERVICE-ORIENTED ARCHITECTURE MICROSERVICES ARCHITECTURE
最大化应用程序服务的可重用性 专注于解耦
系统化的改变需要修改整体 系统化的改变是创建一个新的服务
DevOps和持续交付正在变得流行,但并不是主流 专注于DevOps和持续交付
关注业务功能重用 更加强调“边界上下文”
对于通信,它使用企业服务总线(ESB) 对于通信使用不那么复杂和简单的消息传递系统
支持多种消息协议 使用轻量级协议,如HTTP、REST或Thrift api
使用一个公共平台让所有的服务部署到上面去 应用服务器并不是实际被使用的, 通常使用云平台
使用容器(如Docker)就不那么流行了 容器与微服务配合得非常好
SOA服务共享数据存储 每个微服务都有独立的数据存储
共同治理和标准 放松管理,更加注重团队协作和选择的自由

I’ll get into more detail in some of the aspects shown in the table above and further explain the differences:

  • Development – In both architectures, services can be developed in different programming languages and tools, which brings technology diversity into the development team. The development can be organized within multiple teams, however, in SOA, each team needs to know about the common communication mechanism. On the other hand, with microservices, the services can operate and be deployed independently of other services. So, it is easier to deploy new versions of microservices frequently or scale a service independently. You can read further about these benefits of microservices here.

开发-在这两种体系结构中,服务都可以用不同的编程语言和工具开发,这为开发团队带来了技术多样性。开发可以在多个团队中组织,但是在SOA中,每个团队都需要了解公共通信机制。另一方面,使用微服务,服务可以独立于其他服务进行操作和部署。因此,更容易频繁地部署微服务的新版本或独立地扩展服务。您可以在这里进一步了解微服务的这些好处。

  • “Bounded Context” - SOA encourages sharing of components, whereas microservices try to minimize on sharing through “bounded context.” A bounded context refers to the coupling of a component and its data as a single unit with minimal dependencies. As SOA relies on multiple services to fulfill a business request, systems built on SOA are likely to be slower than microservices.

“绑定上下文”——SOA鼓励组件共享,而微服务则尽量减少通过“有界上下文”的共享。有界上下文指的是组件与其数据之间的耦合,它是一个具有最小依赖关系的单一单元。由于SOA依赖于多个服务来满足业务请求,基于SOA构建的系统可能比微服务慢。

  • Communication - In SOA, the ESB could become a single point of failure which impacts the entire system. Since every service is communicating through the ESB, if one of the services slows down, it could clog up the ESB with requests for that service. On the other hand, microservices are much better in error tolerance. For example, if one microservice has a memory fault, then only that microservice will be affected. All the other microservices will continue to handle requests regularly.

通信-在SOA中,ESB可能成为影响整个系统的单一故障点。由于每个服务都是通过ESB进行通信的,如果其中一个服务的速度变慢,它可能会用对该服务的请求阻塞ESB。另一方面,微服务的容错性要好得多。例如,如果一个微服务有内存错误,那么只会影响该微服务。所有其他微服务将继续定期处理请求。

  • Interoperability - SOA promotes the use of multiple heterogeneous protocols through its messaging middleware component. Microservices attempt to simplify the architecture pattern by reducing the number of choices for integration. So, if you want to integrate several systems using different protocols in a heterogeneous environment, you need to consider SOA. If all your services could be accessed through the same remote access protocol, then microservices are a better option for you.

互操作性- SOA通过其消息传递中间件组件促进了多种异构协议的使用。微服务试图通过减少集成选择的数量来简化体系结构模式。因此,如果希望在异构环境中集成使用不同协议的多个系统,需要考虑SOA。如果所有服务都可以通过相同的远程访问协议访问,那么微服务是更好的选择。

  • Size - Last but not least, the main difference between SOA and microservices lies in the size and scope. The prefix “micro” in microservices refers to the granularity of the internal components, meaning they have to be significantly smaller than what SOA tends to be. Service components within microservices generally have a single purpose and they do that one thing really well. On the other hand, in SOA services usually include much more business functionality, and they are often implemented as complete subsystems.

最后但并非最不重要的一点,SOA和微服务之间的主要区别在于大小和范围。微服务中的前缀“micro”指的是内部组件的粒度,这意味着它们必须比SOA的粒度小得多。微服务中的服务组件通常只有一个目的,而且它们在这一点上做得非常好。另一方面,在SOA中,服务通常包含更多的业务功能,并且它们通常作为完整的子系统实现。

Conclusion

One cannot simply say that one architecture is better than the other. It mainly depends on the purpose of the application you are building. SOA is better suited for larger, complex enterprise application environments that require integration with many other applications. That being said, smaller applications are not a good fit for SOA as they don’t need a messaging middleware component. Microservices, on the other hand, are better suited for smaller and well-partitioned, web-based systems. Also, if you are developing a mobile or web application, then microservices give you much greater control as a developer. Finally, we can conclude that since they serve different purposes – microservices and SOA are indeed distinct types of architectures.

不能简单地说一种架构优于另一种架构。这主要取决于您正在构建的应用程序的目的。SOA更适合于需要与许多其他应用程序集成的大型、复杂的企业应用程序环境。也就是说,较小的应用程序并不适合SOA,因为它们不需要消息传递中间件组件。另一方面,微服务更适合较小的、分区良好的基于web的系统。此外,如果您正在开发移动或web应用程序,那么微服务将为开发人员提供更大的控制权。最后,我们可以得出这样的结论,因为它们服务于不同的目的——微服务和SOA确实是不同类型的体系结构。