In this article, we are going to discuss Microservice Architecture over monolithic architecture. The understanding of these architectures helps to decide which architecture is suitable for you and your project.
As the first discussion, What is the monolithic application?
- Monolithic applications have a single file for an entire application. It means that our entire application is packed into a file. It may be a .war or .jar file or any arch file. All the programs of the application such as UI, server-side, database programs are in a single zip file.
The problems with the monolithic application
- Suppose, we want to update or modify a simple thing on the application like changing the colour of a button, then we need to unzip and edit then test the entire application. In this case, we may need to put our application offline too. So, it is one kind of problem in a monolithic application.
- The second one is that as it is with a huge codebase, we need more to maintain this application. If there is any issue or bug, no one can easily find out or debug the application as much as possible. So debugging is a hard process in monolithic applications and hard to install the monolithic applications as well.
But, we have advantages of the monolithic applications among the above-mentioned disadvantages.
- It is easy to test. Especially for the Integration test. No dependency
- It is easy to deploy because It is a single file.
- It is easy to monitor because It is one application therefore we know the extract path of the application.
Actually, microservices architecture is the opposite of monolithic architecture. Because, In Monolithic architecture, each module of an application is packed as a single unit. whereas, In the microservice architecture, the modules are broken down into small independent units as services.
The services have relationships with the Domain-Driven Design approach. Each service is separated based on the domain and can be developed, tested, scaled and deployed independently.
A service can have its own scope and communicate with other services through the APIs. All the services have their logic and database independently, loosely coupled.
In short, the microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API.
by : Martin Fowler
Although, The microservice architecture has extra complexity. So it is hard to develop, test and maintenance.
Characteristics of Microservices Architecture.
- Domain-Driven design approaches. Microservices architecture must have an extracted defined scope for each service/module. So that, services do not share their libraries, database or any other dependencies among them.
- Running own process. not running with another process, able to run independently.
- Communicate with other services via lightweight way mainly use HTTP.
- Able to scale and deploy independently.
- A small team can (10–12 people) able to develop an application with Microservices.
- We can choose any programming language as our wish for different services and can work or connect together.
The scalability is the most unique thing in a microservice architecture because service is separated as one component of an entire application. The book, “The art of scalability ” describes the three-dimensional scale via scale cube. The below scale cube image has three dimensional. Let's see one by one.
X-axis Scaling : X-axis is telling that scaling an application by making multiple copies/instances of the application and running the application behind the load balancer. When a lot of requests come to our server, our server will face traffic, maybe it can not handle. So, we can scale our application making an application and run behind the load balancer, the loaded balancer is nothing but deciding which request is for which server it means that clear the traffic. This is used in common applications.
Z-axis Scaling : Z-axis is similar to X-axis .but each service handle the subset of data.
Y-axis Scaling : The Y-axis scaling is used in a microservices architecture. We split out an application into smaller services or modules. It means that we can have decomposition on the applications.
An additional thing to keep in mind, when we decide to move or start our project with microservices architecture.
- We can use different programming languages for different services
- Its approach has a relation with the Domain-Driven design approach.
- Service resilience and fault tolerance must be implemented. Entire application work based on communicating between the services, If one or two services fails to give responses, We need to have a proper alternative or resolution for this issue.
- We must select an appropriate framework for the development.
- We must have a full stack team that is able to handle the entire part of the projects in any situation.
However, We have the responsibility to select the most appropriate architecture for our application at the planning state.
Suppose, we have the smallest team with 3- 4 members and a project in a startup company, then the monolithic architecture may be a better solution for us. Otherhand, If we have a plan to develop a big Application like E-commerce and decide to scale the application in future, and have some microservice architecture in our team, then, we can go with the microservice architecture.
The Scale Cube
The book, The Art of Scalability, describes a really useful, three dimension scalability model: the scale cube. In this…