What is Monolithic Architecture?
Monolithic applications are big fat complex single applications that have high complexity. Besides, they are hard to maintain and not easily deployable as well. Failure in one part can bring the whole system down. Higher database complexity, Improper resource utilization etc.
To give you a better idea of what monolithic architecture is, here are some of their characteristics:
- They are a really large single application which serves all the types of browsers, mobile applications or any 3rd party integrations.
- They are very complex and have huge structures and files.
- Monolithic apps are very Hard to maintain. (In terms of coding standards, Bug Fixing etc…)
- Continued Development will be difficult as large applications cannot deploy very frequently. (Due to the fear of failure, deployment can be time consuming, you should have to interrupt background jobs before deployment so it will increase the risk factor which leads to fear of deploying frequently.)
- Scaling of applications can be difficult. For example, if there is a single application which is doing all the tasks, there might be a chance that some modules need more CPU consumption, some need higher RAM and some need higher graphics or higher I/O operation. When we provide the application higher ram or CPU it doesn’t mean that the module that really needed that is consuming that resource.
- Horizontal scaling is very hard.
- Development teams usually find scaling monolithic apps difficult. Once an application gets over a certain size, it is really hard to maintain by a single team and then have to divide a team module wise and interference of modules to each other leads to a developer having broad understanding that will become time consuming and also affect the productivity of newly introduced developers.
- Technology become a bottleneck. Once application started development in specific technology then needs to stick with that technology though it becomes outdated.
- Overloaded IDE due to the large application which will take too much time to open the application and build it or deploying it. So, developer needs to spent lot of time in this.
- Large applications take a longer time to start up which will have an impact on deployment as well as affect the productivity of the developer.
The above image illustrates the typical architecture of a Monolithic Application, where a single application contains all the services which are responsible to do all the tasks.
What is Microservice?
A microservice is an architectural concept. It is a distinctive method of developing software systems that tries to focus on modules and divides the whole system into fragments in a way that each module becomes an independent service. In simple words, it involves dividing a single huge system that is hard to maintain into smaller services which are independent and highly maintainable.
The Following are the characteristics of microservices.
- Each Service should be loosely coupled.
- Each Service should be highly maintainable & scalable.
- Each Service should be independently deployable.
- Each service has specific responsibility based on business capabilities.
- Each service should be owned by a small team.
For example, looking at the below Image, one can easily identify that there are different types of services that have their own databases.
Here, systems have been divided into a number of microservices which are working without interfering with each other. This is the beauty of the microservices architecture, where each service is one small module which can be worked with minimum interference with other microservice and each service has its own responsibility and can be deployed individually and can be owned by a small team.
Migrating Legacy Application To Microservices
Strangling the Monolithic Application
There are mainly two approaches for migrating monolithic apps into microservices.
- Implement new features or functionality in a separate microservice.
- Extract the new microservice from the existing Monolithic code base.
In this approach, if there is a single monolithic application, new features should be developed in a microservice that contains the separate database and functionality. In this process, if you want any data from the monolithic application, Relative APIs should be built inside the Monolithic App or a new standalone application should be created which will be responsible to just serve the monolithic application.
It is called a glue, which will become a mediator between monolithic and microservices. After this, when the developer has time, they can move the modules from monolithic to the new microservices. After a certain period of time, one can have only microservices without any monolithic application.
Suppose there is one Food Order and Delivery Management Monolithic application and someone wants to strangle that application into microservice by extracting some functionality into a microservice, the image below figure shows what a person needs to do when they have to extract some functionality from monolithic app into microservice:
1. First, Split the code within the Monolithic Application. Meaning, divide the code separately like Order Code and Delivery Code which will be loosely coupled code and reside in same monolithic application
2. Split the Database and separate the database of the extracted service. Here, one should have to add integration glue. This means that a developer has to create a plan to sync between two databases. It can be managed by Triggers or by Code.
3. Define the Separate Service for the Functionality that you want to separate. Here, it is Delivery Management. So, create a separate service for that module.
4. Use Extracted Service as a standalone service. This can be achieved by API gateway. So, API gateway will be responsible to accept the required and divert that request to Monolithic app or newly extracted service.
5. Now it’s time to remove the delivery management code from existing Monolithic Application
By following these steps, one can migrate a typical monolithic application into a microservice based architecture. If you haven’t noticed, having an ideal monolithic to microservices migration strategy is crucial. Without it, the cloud migration process could be chaotic.
So, if you don’t have a solid cloud migration strategy in mind, you could get in touch with us today.
Latest posts by Dhrumil Shah (see all)
- A Definitive Guide To Migrating A Monolithic Application to Microservices - September 20, 2021
- Quick Guide to Azure Service Bus-Messaging Solution - March 18, 2021