Modular Monolithic vs. Microservices

Written by
Written by

When we are building web or software applications, we constantly look for ways to improve our code and use better tools to get the best experience, performance, and many other things, not just on the final client-side but also in the development and deployment process.

Microservice architecture was created in response to challenges faced when building monolithic applications. Microservices aim to be more scalable, flexible, and easier to maintain, however, microservices are not always the best choice - it all depends on your own specific needs.

But wait... what is a monolith app?

A monolith app is the one where the application is a single unit, which means that all the business logic is in one place and if a change is applied to the app, it affects the whole application and needs to be fully deployed again to include the changes working in the production server. Also, this kind of application usually uses only one type of database and one programming language for development.

And what about microservices?

An application built using the microservices architecture is one where the whole application is divided into different pieces of software, each independent of the other, using different programming languages, libraries and frameworks, and even different databases. The changes applied to one of these pieces don't affect the others, making the development process more flexible.

So, we should obviously choose microservices, right?

Well, if you're familiar with monolith applications, there is an alternative that you should know about before considering moving your entire project to a microservices architecture, and it is the modular monolithic architecture, a great way to keep your application as a single unit, but with advantages that before were only found in microservices.

Let's talk about modular monolithic

When we build traditional monolithic software, we divide our logic into different layers to make the development and maintenance of the code much easier:

Traditional monolithic software

This kind of structure is a good way to build efficient software, but not too flexible because any change in the code will affect the whole unit. Because of this, we can use the modular monolithic architecture, before going on to microservices.

What is modular monolithic architecture?

The modular monolithic architecture consists of dividing our logic first into modules, and each module will be independent and isolated. Then, each module should have its own business logic — and, if necessary, its database or schema. In that way you can build and modify the layers of each module without affecting the others:

Modular monolithic architecture

Of course, following this pattern, there should be communication between the modules to work correctly, but this communication must be done through public APIs, allowing access to the logic of each module from the other using public methods, and not using the internal functions and logic of each one.

What are the features of modular monolithic apps vs microservices?

Now, let's compare the features of modular monolithic and microservices architectures to help you know which one could be the best option for your project:

Modular Monolithic:

  • A module is never completely independent. It has dependencies with other modules, but these should be minimal.
  • Modules are interchangeable.
  • Code is reusable.
  • Better organization of the dependencies compared to traditional monolithic apps.
  • Easier to maintain and develop new versions than traditional monolithic apps.
  • You can keep the whole project as a single unit, without needing different servers for deployment.
  • More scalable than traditional monolithic apps.
  • Less complex than microservices architecture.

Microservices:

  • Services are completely independent; each one has its own dependencies and logic.
  • Each service could have a different database (this is optional because they can share the same database, but it's preferred).
  • Each service can use a different programming language and technology.
  • When there is a change in the code, you can deploy only one service without interrupting or affecting the others.
  • CI/CD Cloud-ready.
  • More scalable than modular monolithic apps.

Conclusion

These are just a few features of each one, but I invite you to do more research about the different architectures of software development and use the one that you know is the best option for your specific case. Our Software Architects are ready to discuss your project, contact us or review our playbook to learn more about our technical discovery process.

And, of course, try to master the monolithic and modular monolithic architectures before thinking about refactoring all your code to migrate to a microservices architecture. Neither is perfect for everyone, but one can be perfect for you and your development team.

Frequently Asked Questions