DEV Community

Ankit Kumar
Ankit Kumar

Posted on

So Monolith or Microservice?

MONOLITHIC ARCHITECTURE

A monolithic architecture refers to the fact that your entire application is one large project or codebase. Let’s say you were building an online store. This single codebase must be responsible for every concern of the application from login, to account management, to the product listings, to the shopping cart, payment processing etc.

It sounds immediately critical but there's advantage of monolithic architecture as well.
1. Monoliths are also generally easier to test, as all of their components are in one place for end-to-end access.
2. They are also easy to deploy and scale horizontally as a single package that you can place on multiple server instances.
3. Initial development of monolithic architecture is fast because it is built with the mindset that all parts should be interconnected and dependent on each other.
4. Monoliths don't require API for communication between components, enabling higher performance.

There are also several drawbacks of it:
1. When you get to an enterprise-level application, a single codebase becomes large and hard to handle.
2. Every change in any feature requires a redeployment of the entire application.
3. Making updates, making additions is time-consuming and need to be carefully coordinated.
4. It is extremely problematic to apply new technology in a monolithic application because then the entire application has to be rewritten.

MICROSERVICE ARCHITECTURE

A microservice architecture aims to break down a large application into several more manageable chunks. Using the example of an online store above, you could have a microservice, or even a micro application, dedicated to login. Another dedicated to your product catalogue. Yet a third to handle payments and/or shipping. Essentially, each concern of the application is broken into a separate project or service.

But there's a double-edged sword, just like the monolith.
There are many advantages to a microservice approach as well though.

  1. Each problem can be handled and managed independently.
  2. It makes the codebases more easily managed and the project can be broken up into more easily managed chunks and handled by specialized teams.
  3. New technologies can be adopted more easily, as you can update the services one by one, rather than all at once.
  4. Changes and enhancements to the application don’t require the entire application to be deployed.

The major disadvantage of Microservice is

  1. The initial deployment and development of a microservices architecture requires a high number of resources and can take time. Since there needs to be a seamless integration of the varying individual components.
  2. Due to the complexity of this architecture, testing can prove to be difficult, especially in terms of the interactions between services.

So Monolith or Microservice?
Choosing a monolithic architecture: Small teams, simple application, fast deployment, No microservice expertise, quick release.

Choosing a microservice architecture: Complex and scalable application, long term plans, larger data scale, have a team with different language expertise.

Top comments (0)