Monolithic vs Microservices

There is a common misconception when we talk about monolithic architecture, we think of those which have huge systems and it’s just one machine running the entire system which is not true. It doesn’t need to be single in terms of number of machines you are running it on because there might be multiple machines for the same monolithic and these clients can connect to them, they in turn can connect to this database or two more databases so you can horizontally scale.

Micro service is a single business unit for all data and functions which are relevant to a service are put into one service. If you can separate it with a lot of concerns being separated out, then you probably want to separate a single service into pieces. Microservices themselves talk to their own dedicated databases. Client may not be talking to the micro service directly it might be talking to a gateway so these clients will be connected to the gateway and this gateway is talking to these micro services.

Advantages of Monolithic Architecture

Monolithic Architecture when put on under a lot of load scales out into multiple servers. One of the advantages of this architecture is when you have a small or cohesive team, you may not have the effort and time required to break this into a microservice. The architecture is less complex since there are lesser moving parts and deployments are somewhat easier.

There will be lesser duplication of code in monolithic as all that code which is used for setting up tests and connections in your system need not be duplicated for every service that you create it’s all the same it’s all in one service. Monolithic applications are faster as there are no network calls being made. Everything resides inside the same box and all it needs are local calls.

Disadvantages of Monolithic Architecture

More context is required for a new member of team as they must go through all the logic and understand the system before they can start working. Deployments are complicated as any change in code requires a new deployment and the code is going to get deployed frequently and needs to be monitored to verify the code is working completely.

Tests are also complicated as everything is linked with another and its not really decoupled to verify every scenario. There is too much responsibility on each server and if there was a failure in server entire application is taken down. So, there is a bottle neck of having a single point of failure.

Advantages of Microservices

The obvious advantage of microservices is it can be scaled very easily because each service is concerned with only its data and interacting with each other so it’s easier to design the system in that way. The second thing is whenever there’s a new developer coming into the team you can assign them a task which concerns with a service, so they just need to know the context of this service instead of the entire monolithic.

Parallel development is easy because there is lesser dependency for the developers working on different services now because they can develop at the same time in the monolithic maybe one function is calling the other function and it’s changing so there’s a lot of coupling tight coupling not just in code but also in the developer time. This would also make testing easier so that each end point is thoroughly tested for the expected output.

There are very few parts which are hidden when you are deploying this service, this help us to know which service is having maximum load and we can put more machines for that service to scale it. In monolithic its more difficult to say which part of code is hit heavily so you end up putting more servers without a streamlined approach.

Disadvantages of Microservices

Microservices are not easy to design. For example, if a service always calls another service all the time that implies it should have been within a single service and they could have converted the network call to a local call.

Also having a dedicated database to individual service is the ideal way of designing microservices but if it’s a large project having multiple microservices then having multiple databases would be painful.

 

#12DayOf100DaysOfCode

Last modified: March 23, 2019

Author

Comments

Write a Reply or Comment

Your email address will not be published.