Microservices and Service Oriented Architecture

0
4243
6 min read

Microservices are an architecture style and an approach for software development to satisfy modern business demands. They are not a new invention as such. They are instead an evolution of previous architecture styles. Many organizations today use them – they can improve organizational agility, speed of delivery, and ability to scale. Microservices give you a way to develop more physically separated modular applications.

This tutorial has been taken from Spring 5.0 Microsevices – Second Edition

Microservices are similar to conventional service-oriented architectures. In this article, we will see how microservices are related to SOA.

The emergence of microservices

Many organizations, such as Netflix, Amazon, and eBay, successfully used what is known as the ‘divide and conquer’ technique to functionally partition their monolithic applications into smaller atomic units. Each one performs a single function – a ‘service’. These organizations solved a number of prevailing issues they were experiencing with their monolithic application. Following the success of these organizations, many other organizations started adopting this as a common pattern to refactor their monolithic applications. Later, evangelists termed this pattern as microservices architecture.

Microservices originated from the idea of Hexagonal Architecture, coined by Alistair Cockburn back in 2005. Hexagonal Architecture or Hexagonal pattern is also known as the Ports and Adapters pattern. Cockburn defined microservices as:


“…an architectural style or an approach for building IT systems as a set of business capabilities that are autonomous, self contained, and loosely coupled.”

The following diagram depicts a traditional N-tier application architecture having presentation layer, business layer, and database layer:

Spring 5.0 Microsevices

Modules A, B, and C represent three different business capabilities. The layers in the diagram represent separation of architecture concerns. Each layer holds all three business capabilities pertaining to that layer. Presentation layer has web components of all three modules, business layer has business components of all three modules, and database hosts tables of all three modules. In most cases, layers are physically spreadable, whereas modules within a layer are hardwired.

Let’s now examine a microservice-based architecture:

Spring 5.0 Microsevices

As we can see in the preceding diagram, the boundaries are inversed in the microservices architecture. Each vertical slice represents a microservice. Each microservice will have its own presentation layer, business layer, and database layer. Microservices is aligned toward business capabilities. By doing so, changes to one microservice do not impact the others.

There is no standard for communication or transport mechanisms for microservices. In general, microservices communicate with each other using widely adopted lightweight protocols, such as HTTP and REST, or messaging protocols, such as JMS or AMQP. In specific cases, one might choose more optimized communication protocols, such as Thrift, ZeroMQ, Protocol Buffers, or Avro.

As microservices is more aligned to the business capabilities and has independently manageable lifecycles, they are the ideal choice for enterprises embarking on DevOps and cloud. DevOps and cloud are two facets of microservices.

How do microservices compare to Service Oriented Architectures?

One of the common question arises when dealing with microservices architecture is, how is it different from SOA. SOA and microservices follow similar concepts. Earlier in this article, we saw that microservices is evolved from SOA and many service characteristics that are common in both approaches. However, are they the same or different?

As microservices evolved from SOA, many characteristics of microservices is similar to SOA. Let’s first examine the definition of SOA.

The Open Group definition of SOA is as follows:

SOA is an architectural style that supports service-orientation. Service-orientation is a way of thinking in terms of services and service-based development and the outcomes of services.

  • Is self-contained
  • May be composed of other services
  • Is a “black box” to consumers of the service

You have learned similar aspects in microservices as well. So, in what way is microservices different? The answer is–it depends.

The answer to the previous question could be yes or no, depending upon the organization and its adoption of SOA. SOA is a broader term and different organizations approached SOA differently to solve different organizational problems. The difference between microservices and SOA is in the way based on how an organization approaches SOA.

In order to get clarity, a few cases will be examined here.

Service oriented integration

Service-oriented integration refers to a service-based integration approach used by many organizations:

Spring 5.0 Microsevices

Many organizations would have used SOA primarily to solve their integration complexities, also known as integration spaghetti. Generally, this is termed as Service Oriented Integration (SOI). In such cases, applications communicate with each other through a common integration layer using standard protocols and message formats, such as SOAP/XML-based web services over HTTP or Java Message Service (JMS). These types of organizations focus on Enterprise Integration Patterns (EIP) to model their integration requirements. This approach strongly relies on heavyweight Enterprise Service Bus (ESB),such as TIBCO Business Works, WebSphere ESB, Oracle ESB, and the likes. Most of the ESB vendors also packed a set of related product, such as Rules Engines, Business Process Management Engines, and so on as a SOA suite. Such organization’s integrations are deeply rooted into these products. They either write heavy orchestration logic in the ESB layer or business logic itself in the service bus. In both cases, all enterprise services are deployed and accessed through the ESB. These services are managed through an enterprise governance model. For such organizations, microservices is altogether different from SOA.

Legacy modernization

SOA is also used to build service layers on top of legacy applications which is shown in the following diagram:

Spring 5.0 Microsevices

Another category of organizations would have used SOA in transformation projects or legacy modernization projects. In such cases, the services are built and deployed in the ESB connecting to backend systems using ESB adapters. For these organizations, microservices are different from SOA.

Service oriented application

Some organizations would have adopted SOA at an application level:

Spring 5.0 Microsevices

In this approach as shown in the preceding diagram, lightweight Integration frameworks, such as Apache Camel or Spring Integration, are embedded within applications to handle service related cross-cutting capabilities, such as protocol mediation, parallel execution, orchestration, and service integration. As some of the lightweight integration frameworks had native Java object support, such applications would have even used native Plain Old Java Objects (POJO) services for integration and data exchange between services. As a result, all services have to be packaged as one monolithic web archive. Such organizations could see microservices as the next logical step of their SOA.

Monolithic migration using SOA

The following diagram represents Logical System Boundaries:

Spring 5.0 Microsevices

The last possibility is transforming a monolithic application into smaller units after hitting the breaking point with the monolithic system. They would have broken the application into smaller physically deployable subsystems, similar to the Y axis scaling approach explained earlier and deployed them as web archives on web servers or as jars deployed on some home grown containers. These subsystems as service would have used web services or other lightweight protocols to exchange data between services. They would have also used SOA and service design principles to achieve this. For such organizations, they may tend to think that microservices is the same old wine in a new bottle.


Further resources on this subject:


LEAVE A REPLY

Please enter your comment!
Please enter your name here