As development teams require more flexibility, scalability and speed, traditional monolithic software development models have become largely obsolete. To meet the needs of the modern landscape, two options have emerged for effectively and efficiently building and running large-scale, complex applications: service oriented architecture (SOA) and microservices.
Which model is the best for your business? While these two approaches may appear very similar at first glance, there are several notable differences that could help your development team decide which model is ideal for your business. In this post we explore both SOA and microservices, their main differences and some high-level use cases of each.
SOA and Microservices: An Overview
Before discussing the differences of SOA and microservices, let’s take a quick look at their similarities. Both SOA and microservices:
- Break down large-scale, complex applications into smaller, more flexible components
- Offer enhanced scalability to help the organization develop and deploy apps more quickly
- Are agile development models based on a cloud or hybrid cloud environment
But what sets them apart? In fact, there are several important differences between SOA and microservices with respect to scope, architecture, governance and communication. Here we take a deep dive into each model and how they compare.
What is SOA?
Service-oriented architecture (SOA) is a cloud-based software development model that breaks down required application components into distinct service modules. These modules are smaller and more flexible than monolithic applications, making them easier to work with.
There are four main services delivered by SOA:
- Functional services, or business services, which pertain to business applications or business operations
- Enterprise services, which are used to implement the functionality
- Application services, which refer specifically to developing and deploying apps
- Infrastructure services, which relate to backend, non-functional processes such as security, access and authentication
Each SOA service consists of three components:
- The interface, which outlines how the service provider will manage requests from the consumer.
- The contract, which defines the terms of interaction between the provider and service consumer.
- The implementation, or service code.
SOA services can also be combined to develop more complex services and applications. Typically, the SOA connects these modules through a robust communication and control layer called an enterprise service bus (ESB).
The SOA structure is based on the concept of “loose coupling.” This means that components do not require complex point-to-point integration as is the case in a monolithic architecture. This allows different components to communicate via the ESB even if they are based on a different platform or programming language. As such, the development team can reuse modules to fulfill different purposes throughout the enterprise, which decreases the time developers need to spend rebuilding individual components for each web application.
That said, one drawback to SOA is that if a component contains a flaw or bug, it will affect all instances where it is implemented. As a result, problems within the code or another component of each module can have widespread effects across the enterprise if they are deployed at scale.
What is a microservice?
A microservices architecture is considered an outgrowth of SOA. It also breaks down large-scale applications into smaller, more flexible components — but does so with even more granularity. It also organizes each unit around a specific, highly specialized business function.
Microservices operate according to a principle known as bounded context, which is the ability to position a component and its data as a standalone unit or one with limited dependencies. In other words, services are decoupled and function independently. As such, if one web service fails within an application, other services associated with the app will continue to operate as usual.
In a microservices model, services leverage an application programming interface (API) to communicate with other services, components and applications. When connected through the API, independent services can be united to create a complex application.
Because services are independent in a microservice architecture and because the model itself usually leverages containers to operate, the microservices approach generally has more scalability, portability and fault tolerance as compared to other software development models, including SOA.
Microservices vs SOA: Identifying the Differences
The main difference between SOA and microservices has to do with the architecture scope. In an SOA model, services or modules are shared and reused enterprise-wide, whereas a microservice architecture is built on individual services that function independently. In other words, SOA has an enterprise scope, while microservices has an application scope.
This distinction, in turn, drives several critical differences between the two models:
Reusability vs Data Duplication
In an SOA model, developers reuse components as a means of enhancing scalability and efficiency. Following this approach in a microservices model, however, will generally reduce agility and fault tolerance, since reusing a component will create dependencies across different services. Instead, in a microservices architecture, developers reuse code or duplicate data to increase efficiency and maintain high levels of independence.
Synchronous Calls vs Asynchronous Communication
In SOA, services are made available throughout the enterprise via synchronous protocols. Most commonly this comes in the form of RESTful APIs. However, in a microservices architecture, synchronous calls will create real-time dependencies, which in turn reduces reliability and resiliency. To avoid these issues and maintain high levels of performance, developers enable asynchronous communication via techniques such as event sourcing or a publish/subscribe model.
Source Data vs Local Data
In SOA, all applications should be able to receive and update data at the source level at the same time. As such, SOA services do not need to include complex data synchronization models. However, this approach also creates dependencies across services, which is not ideal in a microservices architecture. To maintain independence among all services and applications, a microservices model provides local access to all data needed by each service. This creates instances of data duplication and, by extension, complexity, but avoids dependencies that could impact performance.
ESB vs API
In an SOA, services are organized and coordinated through a common communication channel called an enterprise service bus (ESB). Since all communication is centralized within the ESB, this introduces the risk of a single point of failure for all services. To avoid this issue and maintain independent operation, microservices communicate via API.
These points, plus several additional differences, are summarized in the chart below:
|Architecture||Services are reused and shared at the enterprise level||Services are decoupled and operate independently
|Granularity||Relatively large, modular services||Smaller, more flexible services that serve a specific purpose or function to the business
|Coupling||Resource sharing/loose coupling||Bounded context|
|Interoperability||Supports multiple message protocols such as Simple Object Access Protocol (SOAP), Advanced Messaging Queuing Protocol (AMQP) and Microsoft Messaging Queuing (MMQ)||Uses lightweight, language-agnostic messaging protocols such as HTTP, Representational State Transfers (REST) or Java Messaging Service (JMS)|
|Data governance||Common data governance across the enterprise as a result of component sharing||No consistent data governance among teams due to the independent nature of services|
|Storage||Single data storage layer shared by all services within a given application||Independent data server or database for data storage for each service, as required|
Microservices vs SOA: Which is better for your business?
SOA and microservices each have distinct advantages and disadvantages. Choosing which architecture is right for your business often depends on your use case, as well as your available resources, IT maturity and business needs.
When SOA Is Right for You
Larger, more diverse application environments tend to benefit from SOA because it enables robust integration through the ESB. This allows developers to connect heterogeneous applications and a variety of messaging protocols, while still allowing each app to maintain its independence.
That said, SOA deployments tend to be slower and more complex than microservices. This is because multiple services are coupled together, which means that adding a new service or feature will entail some degree of redeployment for the whole application.
Specific use cases that are well-suited for SOA include:
- Enabling communication between multiple independent apps
- Building a service with the express purpose of being reused one or more times throughout the enterprise
- Supporting an app with multiple data sources
- Exposing data or functionality to external clients
- Building serverless functions
When Microservices Is Right for You
A microservices architecture tends to be easier and faster to build as compared to an SOA. This is because the services themselves are smaller and therefore easier and faster to deploy.
Organizations that operate smaller, less complex environments and do not require a robust communication platform generally find that a microservices approach offers greater speed, flexibility and resiliency and often entails lower cost and complexity.
Microservices are ideal in the following scenarios:
- Relatively simple projects that can be easily broken down
- Complex apps that have either already been broken down or have a clear way of doing so
- Organizations that want to embrace agile development and continuous delivery processes
- Businesses that want or need to optimize cloud computing resources, particularly through the use of containers
- Applications that use multiple frameworks, languages and technologies in the same environment