Application architecture is about making fundamental structural choices that are costly to change once implemented. Application architecture choices include specific structural options from possibilities in the design of the software. An architectural pattern is a general, reusable solution to a commonly occurring problem in software architecture within a given context. There are many architectural styles and two of the most debated ones are Monolithic Architecture and Microservices Architecture. In this article, we will try to uncover them with an eye on their future compatibility.
Monolithic Architecture vs Microservices Architecture
In software engineering, a monolithic application architecture describes a single-tiered software application in which the user interface and data access code are combined into a single program from a single platform. A monolithic application is self-contained and independent from other computing applications. The various functions of that application are grouped inside a single blob of code which lacks clear interfaces and inter-service communication. The monolithic design approach is that the application is responsible not just for a particular task, but can perform every step needed to complete a particular function, hence, the monolithic application is designed without modularity. Modularity is desirable in general as the application is easy to understand, supports reuse of parts of the application logic and also facilitates maintenance by allowing repair or replacement of parts of the application without requiring wholesale replacement. Monolithic Architecture falls short in some of the important architectural aspects of Modularity, Reusability, Extensibility, Scalability and Maintainability.
Microservices architecture is opposite to the traditional, monolithic approaches. In this design approach, functionality is broken down into its core functions. Each function is called service and can be built and deployed independently, meaning individual services can function (and fail) without negatively affecting the other functions.
What are Microservices?
Microservices are an anti-monolithic piece of code. They are a self-contained piece of business functionality with clear interfaces. They normally serve one purpose and serve them well, i.e. all the scenarios of the service are well-handled.
How do Microservices work?
The very idea of loosely coupled services that are highly maintainable and testable sounds challenging to businesses that face IT challenges due to complex applications. But before replacing or refactoring the system in place, it is vital to understand how microservices work.
To create a functioning modular architecture, a business needs to first identify its functions/domains and define the services in them that will run independently from each other. A microservice architecture diagram is needed. The architecture diagram focus is to expose service dependencies that would hinder the flexibility of each service and service dependencies in cross-business functions as it is critical to ensure that an error in an individual part wouldn’t impact the whole system. This can be achieved by service-isolation by reducing dependencies or increasing the reliance of the service.
Key Benefits of Microservices
Service granularity: Microservices are granular, but how much? It depends on the business and organizational context. There is no single measurement to determine how granular a microservice should be. Service granularity makes the system easy to understand, develop, maintain and scale.
Modularity: The application developed in microservices is easy to understand, develop and test. The architecture will last longer and changes will be easier and focused.
Integration: use of the microservices for the integration of heterogeneous and legacy systems is a viable option.
Easy scalability: Microservice is independent, well defined, single-purpose services. Since microservices are implemented and deployed independently of each other, they can be monitored and scaled independently.
Parallel development: Microservices make it easy to enable parallel development by enabling small autonomous teams to develop, deploy and scale their respective services independently. It also enables improvement of existing architecture through continuous refactoring of existing monolithic services into microservices. Microservice-based architectures facilitate continuous integration, continuous delivery and deployment.
Technology agnostic: Microservices can be defined as processes that often communicate over a network using technology-agnostic protocols. Microservices are also built to suit business capabilities. Since they are decentralized and small in size, they offer a lot of flexibility when it comes to programming languages, hardware, and software environments.
What is Microservices Architecture?
Microservice Architecture (MSA) as a variant of Service Oriented Architecture (SOA), arranges an application as a collection of loosely coupled services. Microservices are fine-grained and the protocols are lightweight. Microservices architecture describes a particular style in which software applications are designed.
In contrast to traditional architectural styles that aim to build software like a single unit, microservices architecture is based on a modular approach. The application is divided into smaller components that are built as independent services. They can be updated or even replaced easily without any major overhaul to the application. As they are decentralized and small in size, they offer a lot of flexibility when it comes to programming languages, hardware, and software environments.
Characteristics of a Microservices Architecture
- In a microservice architecture (MSA), services communicate over a network to fulfil a goal using technology-agnostic protocols such as HTTP.
- Services are grouped and organized around the business domain and capabilities.
- Services in a microservice architecture are independently deployable.
- Services are technology agnostic, i.e. services can be implemented using different programming languages, databases, hardware and software environments.
- Services are small in size, serve a very specific purpose or bounded by contexts, autonomously developed, independently deployable, decentralized and built and released with automated processes.
Role of Composite services in Microservices Architecture
The microservices are designed to work independently but they sometimes still have dependencies on other microservices and need to communicate with each other. This communication occurs through the use of APIs (Application Programming Interfaces). It can be synchronous or asynchronous using protocols like HTTP/REST or AMQP. The responsibility for such communication is given to the special services called Composite/Business services. These composite services help to avoid problems that arise from the growth of microservices interdependencies. A composite service takes requests and then routes every single one to the most appropriate microservice. It also invokes backend services and aggregates the results to identify the best path. It serves as the entry point for every request in a business context, organizes all input, and creates a simplified user experience.
Success Story of Microservices Architecture
Netflix has been so successful moving to a cloud-based microservices architecture, that the company has open-sourced many of the tools and components used to build it. Netflix is one of the earliest adopters of microservices, a term that didn’t even exist when Netflix began moving away from its monolith. Today, the Netflix application is powered by an architecture featuring an API Gateway that handles about two billion API edge requests every day which is handled by approximately 500+ microservices. Netflix has been so successful with its architecture, that the company has open-sourced the majority of its platforms including the technologies powering its microservices. Netflix has become one of the most well-known examples of modern microservices architecture; if an article mentions microservices, odds are, it also mentions Netflix.
Some of the other notable microservice adopters are Zalando, Spotify and Royal Mail.