System Design ( Day - 14 )

Migrating from Monolithic to MicroServices
Monolithic is nothing but a single code base which contains all types of services present in it
MicroServices is nothing but a same monolithic services which are divided into several services as per the requirements the particular services will be will be called.
Advantages of Monolith
1. Duplication is lesser
2. good for smaller teams
3. contracts are in once place
Advantages of MicroServices
1. Seperation of concern
2. Code changes will be easier
3. Deployments are easier (which means we can make change in any of the Service and deploy that)
Steps for Migration
We need to build each services, Integrate DB’s and, Redirect users into it. Effort of doing it is huge.
What we can do is if we add another feature to our existing monolith architecture we can start that new feature in another service to get into the microservice architecture, earlier what happens is in monolithic we are calling any of the services through the function calls, but now we have to make a HTTP or gRPC call or we can use any messaging queues, new the new service is having its own code repository, so we can assign a new team for that service and maintain over there.
We need to do some infrastructure changes also, like how are these each services are gonna talk with each other, through http or something, but we have to define a contract for the object to form, when ever any of the service want to call any service then that service has to read the contract and define the object as it is to make the calls over the network,
If i want to talk to my service then i’ll create a library, to get the access for the service, if i want to call that service then i have to call the a method in that library, what if my library is not upto date, then obviously my code will crash, that’s normal
We need something for routing like loadbalancer or service registry something like that, for the routing to each service and Deployments will be faster, communication between the services would be different, like http calls like request / response, or gRPC or message queues.
Logging is also important, we can’t go to each service and check their logs instead of this what we can do is Elastic stack and we can take all of the logs from the messaging queue like kafka or something else and then we can store that logs and check them whenever we need.
When we are converting from monolithic to microservices, we have to think like we have to find a feature and then we have to encapsulate that feature complete details and everything into one place and make it as a service.
Each service can have their individual Database, and so that if we are asking for some data in the service then it should take from it’s own database, it should not be like im asking for one data then that service is asking for another database its actually not good. yes we have to get the data in another service, that’s another case. and also cost of infrastructure is high for the small teams.
That’s how we can migrate the monolithic project to a microservice project.
Subscribe to my newsletter
Read articles from Manoj Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
