Monolithic vs Microservice Architecture

Introduction

Most of web application developer might discussed about Monolithic vs Microservice. Now a days we can develop better web application with either these options. Its all important that which one is right our needs. In this article, we will discusses both of these architecture and you can decide which architecture is needed for application development.

Monolithic vs Microservice

Monolithic

Monolithic architectures are a setup used for traditional server side systems. The entire systems function is based on a single application. For better understanding please see the architecture (Fig 1) .

Fig 1. Monolithic Architecture
Example

To understand better let’s discuss about a small monolithic application as an example to know how it works. And for as example, lets assume Electronic Medical Reports System (EMRS). The major features of this application are,

  • Reception Module – Patients schedule appointments to consult Doctor. If they are old patient then just need to enter the Medical Record Id , and if new patient then new MRI number should be created after registration.
  • Nurse Module– Nurse records the pre-medical required medical data such as current body temperature, Blood Pressure, Heart rates and other required medical data.
  • Doctor Module – Medical investigations and treatment details will recorded by doctor for the patient. And doctor prescribes the medicines.
  • Pharmacy Module – Patients can buy medicines prescribed by doctor based on the MRI number.
  • Accounts Module – Accountant members hospital can generate the financial reports.

The each feature in this application communicates with same database that will be on the same server. With this many functions, lets see what are the Pros and Cons of using Monolithic Architecture for Application.

Pros
  • Its faster to develop – We can create an application with basic features and then scale it up over time.
  • Monolithic applications performs faster than Microservices applications because they (Monolithic) do not have the communicating via APIs.
Cons
  • Maintaining monolithic applications can also become very challenging if specially if they are not developed well. This is because of tightly coupling processes i.e., making a single change can have a domino effects and cause number of issues in different parts of the code base.
  • While Monolithic architecture puts all of the functionality into a single process.
  • Scaling up the application is difficult because need to scale up the whole application.
  • The testing and isolating the problem is not that much easier while comparing with Microservices because we need to test the whole application.
  • If a particular component in our application is failed or down, then there is a chance of getting failed or getting down of the entire application.
  • In terms of business, you may need a single team to work on the whole project whereas in Microservices we can have different teams in different remote locations.
Microservices

Microservice is an architecture where every feature is its own application.

Fig 2. Microservice Architecture
Example

Let’s take the same example which we discussed just above in the Monolithic Application with the same features as,

  • Reception Module
  • Nurse Module
  • Doctor Module
  • Pharmacy Module
  • Accounts Module

In Monolithic, all these features was one Application. But in Microservice, we might have Reception Module just being its own application. And then Nurse module would be its own application. Likewise all the modules would be its own application. Each applications resides on their own server and then each application will be connected to each other using APIs. So once the Patient schedules an appointment to doctor, the Reception application will send this Patient’s appointment to Nurse Application through API.

All of this communication happens using JSON API usually. As said before, the Monolithic architecture puts all of the functionality into a single process. While in Microservices breaks these up into different pieces. So if we build Microservices in right way then we are not having the same coupling and items should not depend on each other the same way that a Monolithic application does.

Each one of these can be tested and developed individually and once the app is up and running the service simply run on separate servers and separate processes all connected to each other. The biggest benefit of using Microservices is the ability to scale up. We can scale up individual components instead of scale up application as a whole.

In addition to scaling side it also is nice to test various components and isolate any problems quickly and easier and it allows to get prompt solution, and also if a components fails our entire system does not have to fail.

However building a small scale applications using Microservices are rare case, just because it takes a lot longer to build and takes more resources and therefore cost the client more. Building larger scale applications using Microservices can be the best approached. We do not need a same team members to develop the Microservice Application, team members can be in remote since we are developing each feature as one application.

Conclusion

In order to take decision on which type of system to use it really comes down to what type of application we need to build, considering the timeline, budget. I hope this article was very helpful and please share you feedbacks in the comments section.

One thought on “Monolithic vs Microservice Architecture

Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

WordPress.com.

Up ↑

%d bloggers like this: