🛒StackOverflow and Shopify are running a Modular Monolith architecture.
Dec 14, 2023
What do they know that you don't? I've held two talks so far about Modular monoliths. Modular monoliths combine the qualities of monolithic and microservices architectures. It's like they take the best of both worlds. Let's dig a bit deeper.
What do they know that you don't?
I've held two talks so far about Modular monoliths.
Modular monoliths combine the qualities of monolithic and microservices architectures.
It's like they take the best of both worlds.
Let's dig a bit deeper.
Modules need to follow strict rules:
- Modules are independent of other modules
- Modules can only call the public API of other modules
- Modules keep their data isolated from other modules
- Modules can't directly query data from other modules
This design promotes modularity and loose coupling.
It's also around this point when the confusion starts.
"How is this different from Microservices architecture?"
You're doing all this work to isolate modules. You force modules to talk using a public API.
It can still be method calls in memory. But a module would expose an abstraction like
IOrdersApi with methods you can call to interact with the module.
This can later be converted from method calls to HTTP calls over the network, if you move to microservices.
But you're deploying everything as a single application.
Here's a quick reminder of the Fallacies of distributed computing.
The fallacies are:
- The network is reliable
- Latency is zero
- Bandwidth is infinite
- The network is secure
- Topology doesn't change
- There is one administrator
- Transport cost is zero
- The network is homogeneous
There's a huge tax you pay for using Microservices.
You don't need to pay this price straight away.
Build a Modular monolith. Define clear Module boundaries. Move to Microservices when you need them.
What do you gain by using Modular Monolith architecture?
You are still working on a Monolith and have just one executable application.
With a Modular Monolith, you get:
- Modularity (of course)
- Ease of debugging (because it's one process)
- Creating new Modules without provisioning infrastructure
- Improve team collaboration (one team per Module)
- A cohesive and loosely coupled system
- Flexibility with databases used
- Ability to move to Microservices with ease
I hope you understand Modular Monoliths better now.
If you don't, I'm working on something that will help.
In early 2024, I'll release a course about Modular Monoliths.
In the meantime, subscribe to The .NET Weekly.
I'll write about Modular monoliths regularly.