May 2, 2018

Textual description of firstImageUrl

Demystifying MicroServices : An architectural pattern (Functional Cohesion and Loose Coupling)

Microservices are one of the increasingly popular architecture patterns and approach for software development to satisfy modern business demands. The architecture of microservices are influenced from "Port and Adapters design pattern" - Core logic and Services are decoupled in such a way that both core logic and services can be tested separately & application logic an can be integrated with any services which are more apt depending on business need and demand.

What does Microservices means / are they invented ? - Microservices are an architectural style or an tried and tested approach to business systems with enriched capabilities that are autonomous, self-contained, and loosely coupled. Many organisations such as Netflix, Amazon, and eBay successfully used the divide-and-conquer technique to functionally partition their monolithic applications into smaller atomic units, each performing a single function.
Many other organisations followed the success story of these companies and started adopting this as a common pattern to refactor their monolithic applications(Monolithic applications are tightly bounded with limited re-usability and limited scalability). Later, tech evangelists termed this pattern as the microservices architecture.

Architectural difference between Monolithic(tightly coupled) VS Microservices (Loosely coupled) applications :
In monolithic architecture, each layer holds all business capabilities pertaining to given layer. The presentation layer has web components of all the three modules, the business layer has all business modules(interconnected with low cohesiveness and tight coupling), and persistence layer stores data related to all business modules.
In contrast to monolithic architecture, each microservices has its own presentation layer, business layer, and database layer. Microservices are atomic entity and built to meet one business capabilities. Microservices carry features of loose coupling and Functional cohesion. Functional cohesion indicates - when parts of a module are grouped because they all contribute to a single well-defined task of the module.
Below diagram shows difference between monolithic and microservice architecture based application workflow.
Monolithic vs MicroServices architecture based application
Microservices break the boundaries of monolithic applications and build a logically independent smaller system of systems. MicroServices follows principles like :
  • Single responsibility per service:  SOLID design principle states that a class should have one, and only one, reason to change. Same analogy can be applied to microservices that a unit - either a class, a function, or a service, should have only one responsibility. A unit with more than one responsibility leads to tight coupling (high coupling and less cohesion).
  • Microservices are autonomous: Microservices are self-contained and independently deployable. It provides an execution environment where specific business need is full-filled in most efficient way. MicroServices is built as a fat Jar (bundle all library dependencies and execution environments such as web servers and containers) embedding all dependencies and run as a standalone Java process.
    How SOA and MicroServices differs at abstraction level:- "Level of autonomy" is one of the major factor which draws a thick line between microservices and SOA. SOA implementations provide service-level abstraction, microservices goes a step ahead and abstract the implementation and execution environment. Microservices can deployed in separate container and with evolution of container technologies like Docker, it has been proven an ideal choice for microservices deployment and act as a catalyst for microservices evolution.
    Containers are portable, independently manageable, lightweight runtime environments. 

Enterprise challenges handling in Microservices: Major enterprise challenges for any rapidly growing scalable applications and better business results are : Agility, Speed of delivery, and Scale.
With adoption of Microservices based architecture for application development and deployment, industry has shifted paradigm from tightly coupled monolithic application to loosely coupled Single Entity, Single Goal application(Services) strategy. Microservices have shown better result in Speed of delivery with scale and cost effectiveness too. Below these parameters matrix has been depicted and compared.
Enterprise challenges(Agility, Speed of delivery, and Scale) matrix plot

Characteristics of Microservices:

  • Services are first-class citizens : Microservices expose service endpoints as APIs and abstract all their implementation details(logic, architecture, and technologies). Microservices are not bound to any specific programming languages and Database, etc.
  • Microservices are lightweight: Microservices are like bijective functions (One to One mapping). True microservices are designed to serve a single business capability and perform only one function. Microservices are typically deployed in Docker containers, which encapsulate the business logic and associated libraries which makes microservices deployment faster at different hosting environment or with different cloud providers.
  • Microservices with polyglot architecture: Microservices are autonomous and abstract everything behind service APIs so it is very possible to have different architectures for different microservices. Depending upon use cases different tech stack can be used internally however for outer world API's resquest/response is as per contract. Below diagram shows two differennt tech stack- using Erlang & elastic search for high performance task/OLAP  and Java & RDBMS for transactional/OLTP operations. Both API's are abstracted by JSON.
    Polyglot architecture abstracted by JSON Request/Response
  • Microservices are distributed and dynamic : Microservices decentralize data and logic in contrast to traditional applications, which consolidate all logic and data into one application boundary. In microservices based architecture each service aligned to a specific business capability and owns its data and logic.
    In Service Oriented Architecture(SOA), services relay on heavyweight enterprise-level products, such as Enterprise Service Bus (ESB). However, microservices don't typically use centralized governance mechanisms and do not relay ESB like product for intelligence. Instead, the business logic and intelligence are embedded as a part of the services themselves.
    SOA implementations heavily relay on static registry and repository configurations to manage services and other artifacts. Microservices implementations use automated mechanisms to build registry information dynamically from the runtime topologies.
  • Self-healing microservices : In order to build fail-safe systems, Self-healing is commonly used in microservices deployments, where the system automatically learns from failures and adjusts itself. 
====*****=====
Location: Bengaluru, Karnataka, India