Monolithic vs. Microservices Architecture

Discussion on Monolithic and Microservices-based architectures and the pros and cons of them

Bhanuka Dissanayake
Level Up Coding

--

Image credit: https://19yw4b240vb03ws8qm25h366-wpengine.netdna-ssl.com/wp-content/uploads/Monolith-vs-Microservices.png

In this article, I will discuss monolithic and microservices-based architectures and the pros and cons of them.

I had a chance to work on an application based on microservices architecture during my internship. I have contributed to some existing microservices as well as worked with a newly added microservice used for authentication. You can refer to some of my experiences got from the authentication service from the below link.

From the learning I got from working with those things, I did some digging on microservices architecture as well as monolithic (traditional) architecture.

What are Monolithic applications?

First, we look at what the word ‘monolithic’ is.

Monolithic, in information technology, means either very large (and possibly imposing) or composed all in one piece, depending on the particular context; the term is used in different ways to describe integrated circuits, organizations, applications and storage systems, among other things.

In a single software application, there can be a lot of components associated with it. For example,

  • Database layer responsible for the database access of the application.
  • Authentication component which is responsible for authenticating users.
  • There can be a component where the business logic of the application is defined.
  • A notification manager for handle all the notifications. etc..

So, all the components are combined into a single program from a single platform in this architecture.

Image by author

Why monolithic?

At the beginning of a project, it is much easier to go with this architecture since it is easy to do the development. It is easy to test, and deployment is also can be done very simply. But this simple approach has a limitation in size and complexity.

Drawbacks of Monolithic Architecture

When the scale of the application grows up, there will be a lot of cons. The size of the application may slow down the start-up time. You have to redeploy the entire application on each update, and also continuous deployment is difficult.

When it comes to reliability, monolithic applications have significant issues. If any component has a bug, then it causes the whole application to bring down the entire process.

As the technologies are growing up rapidly and new technologies are invented, those applications have a big barrier to adopt them. Since changes in frameworks or languages will affect an entire application, it is extremely expensive in both time and cost.

What are microservices?

Instead of keeping distinct software components in the single monolithic application, split all the components into small interconnected pieces and called them microservices.

Each microservice is a small application and has its hexagonal architecture consisting of business logic along with various adapters. Instead of sharing a single database schema with other services, each service has its database schema, depending on the relationship between the application and the database.

Those microservices can be exposed to REST API, RPC, or message-based API, and most services consume APIs provided by other services. Other microservices might implement a web UI.

Image by author

Why microservices?

Using microservices architecture in software development gives a lot of benefits.

Microservices architecture provides the independent deployment of each microservice. No need to redeploy the entire application on each update, and also continuous deployment is possible for complex applications.

When it comes to development, each microservice can be developed independently by a team that is focused on that service. Decomposing the application makes it much easier to faster development, understandable, and maintainable applications.

Adapting to the new technologies is very easy since the developers have the independent to choose the technologies that make sense for their service and not bound to the choices made at the start of the project.

Drawbacks of Microservices Architecture

Distribution of the components of an application creates some disadvantages too. Developers have to face some additional complexity in creating distributed systems.

Partitioned database architecture in microservices-based applications challenges developers some times. Business transactions that update multiple business entities need to update multiple databases owned by different services.

When there is a change that spans multiple microservices, it is more difficult to solve than monolithic applications. We need to carefully plan and coordinate the rollout of changes to each of the services.

Deployment of a monolithic application is easier than a microservices-based application. It is not like the monolithic application as it has a large number of services, and every service needs to be configured, deployed, scaled, and monitored. The successful deployment of a microservices application requires a high level of automation.

Which is better?

So, I think you got an idea of what monolithic applications and microservices-based applications are. For simple, lightweight applications, it is better to use monolithic architecture. If your goal is to go to the microservices architecture, don’t start with monolithic. Microservices architecture is the better choice for complex, evolving applications.

Thank you for reading!

References

[1] Margaret Rouse, Defenition monolithic (2016), whatis.techtarget.com

[2] Anton Kharenko, Monolithic vs. Microservices Architecture (2015), articles.microservices.com

--

--

Software Engineer @ Calcey | Computer Science & Engineering — University of Moratuwa