DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • AI Agents Expose a Design Gap in Microservices Resilience Architecture
  • Cloud Migration of Microservices: Strategy, Risks, and Best Practices
  • Monolith vs Microservices vs Modulith
  • A Comprehensive Analysis of Async Communication in Microservice Architecture

Trending

  • Hallucination Has Real Consequences — Lessons From Building AI Systems
  • The Prompt Isn't Hiding Inside the Image
  • The Art of Token Frugality in Generative AI Applications
  • Querying Without a Query Language
  1. DZone
  2. Software Design and Architecture
  3. Microservices
  4. What Is a Modular Monolith?

What Is a Modular Monolith?

Everyone has started to build software by using the microservices approach, yet it is clear that it was not needed in many cases. Monolith is good enough.

By 
Milan Milanovic user avatar
Milan Milanovic
DZone Core CORE ·
May. 13, 24 · Opinion
Likes (2)
Comment
Save
Tweet
Share
1.7K Views

Join the DZone community and get the full member experience.

Join For Free

In recent years, we have seen a significant increase in apps built using a microservices architecture. We selected this approach mainly because small teams work in isolation without tripping over each other. Yet, this is an organizational problem, not a technical one. We can also build each service using different technologies and scale independently.

Monolith at the Swiss National Exp in 2002, built by Jean Nouvel
Monolith at the Swiss National Exp in 2002, built by Jean Nouvel

With the microservice approach, we have a few disadvantages, too. The system is becoming complex in maintaining and diagnosing issues (logging and tracing). This is very important when dealing with microservices. Yet, we also saw something called “microservice bloatware,” even on Twitter:

Elon Musk tweet regarding microservices bloatware

But there are many more examples of failures of the microservices approach; if you’re not solving a problem at Netflix size, you probably don’t need microservices.

On the other hand, we have monoliths with a lot of lousy wording about them. But building monoliths doesn’t mean something better per se. In the last few years, we have often seen the identification of monoliths with big balls of mud architecture or purely building legacy code, which doesn't mean to be. Yes, monoliths cannot scale or release independent pieces of the system separately, but those are mainly the most significant downsides. Still, you can create tremendous and high-quality code inside. Monolith brings us much less complexity, reduced network calls, more detailed logging, etc. Most subsystems of an entire application or system are stored in the monolith container. It is called self-contained since every system component is housed in a single container.

We can have architected monoliths that will fulfill all our use cases and requested architecture attributes in the system without dealing with the complexity of microservice architecture. The best example is Shopify, which has over 3 million lines of code and is one of the giant monoliths in the world. Instead of rewriting its entire monolith as microservices, Shopify chose modularization as the solution, while they served 1.27 million requests per second during Black Friday. However, there are also more examples of monoliths, such as StackOverflow, Basecamp, or Istio. Also, recently, we saw that one team in Amazon (Prime Video) abandoned microservice architecture in favor of monolith.

We want to build a modular monolith by creating separate modules and working on them while maintaining simplicity. An adequately produced modular monolith can be a good step that can be transformed into a microservice solution tomorrow if needed. So, the recommended path is Monolith > apps > services > microservices.

"You shouldn't start a new project with microservices, even if you're sure your application will be big enough to make it worthwhile."
— Martin Fowler

When we want to build a modular monolith, it is crucial to divide the system into manageable modules before assembling them into a monolith for deployment. As all communication between the modules might result in a cross-network call if you decide to break it into services in the future, high cohesion, and low coupling are crucial in this situation. This means that all inter-module communication must be abstracted, asynchronous, or based on messaging for the modules to handle calls that travel across the network in the future.

Modular monolith architecture

How can we put such a concept in place? We create separate modules; each has its architecture, and those modules are pulled together into a single API gateway. This allows us to deploy the whole system as a monolith, but it will enable us to pull out separate modules into services if needed in the future.

Architecture microservices

Published at DZone with permission of Milan Milanovic. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • AI Agents Expose a Design Gap in Microservices Resilience Architecture
  • Cloud Migration of Microservices: Strategy, Risks, and Best Practices
  • Monolith vs Microservices vs Modulith
  • A Comprehensive Analysis of Async Communication in Microservice Architecture

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook