This is article 3 of 10 in the Mercado Tech Brasil series on solutions architecture. With the requirements clear, the question that comes up in almost every project appears: monolith or microservices? The honest answer is "it depends," and this article shows what it depends on.
Layers: the starting point of any solutions architecture
Whatever style you choose, a good solution separates responsibilities. The best-known approach splits the code into layers: presentation, which receives people or other systems; business rules, where decisions live; and data access, which talks to the database. When the approval rule for a discount changes, only the business layer should need changes. If the change spreads adjustments everywhere, the problem is organization, and switching architectural styles will not fix it.
Monolith or microservices: what changes
Monolith
It is a single application, deployed all at once and usually backed by a single database. It is simple to develop, test and ship, allows local transactions and needs little infrastructure. The risk shows up over time: without discipline, the code becomes a tangle where everything depends on everything, and any small adjustment forces you to redeploy the entire system.
Microservices
These are several small services, each responsible for one business capability and owner of its own data, talking through APIs or events. They allow independent teams, separate deployments and scaling only the part that needs it. In exchange, the complexity moves elsewhere: calls over the network, which can be slow or fail; harder data consistency; and the need for delivery automation, mature monitoring and more people looking after operations.
The middle ground: the modular monolith
A single deployable package, but divided into modules with clear boundaries, such as orders, inventory and billing, that do not access each other's data directly. It is a widely used path: start modular and extract a separate service only when a concrete reason appears.
How to decide between monolith or microservices in solutions architecture
A few questions help move past personal preference:
- How many teams will work on the solution at the same time?
- Do different parts have very different scaling needs, such as an e-commerce catalog during a sales peak compared with supplier registration?
- Does the company already have automated delivery and monitoring in place?
- Is the business understood well enough to know where the boundaries between modules lie?
If most of the answers are "no," a well-modularized monolith tends to be the safer choice. Microservices solve organizational and scaling problems. Adopted too early, they create the worst of both worlds: a distributed system, with all the network complexity, that still has to be deployed together because the parts remain coupled.
Signs that it's time to split
- One module changes far more often than the others and delays the other deliveries.
- One part needs to scale much more than the rest.
- A team becomes the clear owner of a domain and gets stuck waiting for the others.
In practice
Many of the automation solutions I design in consulting are mid-sized: an approval orchestrator, an integration between CRM and ERP, an internal portal. In those cases, I start with well-separated modules in a single application and record the reason for the choice. If growth justifies it, extracting a service becomes much simpler because the boundaries already exist.
Translated from the original in Portuguese. Read the original.