Monolith vs microservices: you should split a monolith when team size, deployment frequency, or scaling bottlenecks make the monolith the primary constraint on delivery speed or reliability. This article explains the signals that indicate it is time to split, how to approach the transition, and when staying monolithic is the better choice.
Background: The Architecture Spectrum
Software architecture exists on a spectrum. At one end is the monolith: a single deployable unit where all components (UI, business logic, data access) run as one process. At the other end are microservices: many small, independently deployable services that communicate over a network, each owning its own data. In between lie modular monoliths, where the codebase is organized into strong modules but still deployed as one unit.
The term microservices gained popularity around 2011–2014, notably through early adopters like Netflix and Amazon, who needed to scale large teams and traffic independently. However, the architectural style is not inherently superior; it trades operational complexity for organizational and scaling flexibility.
How It Works: The Core Differences
In a monolith, a change to any part of the system requires building and deploying the entire application. This simplifies development, testing, and operations because there is one artifact, one runtime, and usually one database. However, as the codebase grows, the deployment becomes riskier and slower, and different teams often step on each other's toes.
Microservices decompose the system into bounded contexts. Each service has its own API, its own data store, and its own deployment pipeline. Teams can develop, deploy, and scale services independently. But this independence comes with costs: network latency, distributed transactions, service discovery, and the need for robust monitoring and tracing.
How to Choose: Signs It’s Time to Split
There is no magic number of lines of code or team size that triggers a split. Instead, look for concrete pain points:
- Deployment frequency stalls: If your team wants to release daily but the monolith's regression test suite takes hours, or a small change requires coordinated releases across many teams, the monolith is slowing you down.
- Scaling is inefficient: If one part of the system (e.g., a report generator) consumes CPU while the rest is I/O-bound, you must scale the entire monolith, wasting resources. Microservices let you scale only the hot service.
- Team ownership is unclear: When multiple teams work on the same codebase and merge conflicts are constant, or a bug in one team's module brings down the whole app, the monolith lacks clear boundaries.
- Technology lock-in: If you want to use a new language or framework for a specific component, a monolith forces you to rewrite everything or stay with the old stack.
- Reliability is compromised: A memory leak in one module can crash the entire application. In a microservices setup, a failure in one service can be isolated (though cascading failures are still possible).
If none of these apply, a monolith is often the pragmatic choice—especially for early-stage products where speed of iteration matters more than scalability.
Common Problems: The Hidden Costs of Splitting
Many teams split a monolith only to find they have traded one set of problems for another. Common pitfalls include:
- Distributed transaction complexity: A business operation that spans multiple services (e.g., placing an order that updates inventory, payment, and shipping) now requires sagas or eventual consistency, which are harder to reason about.
- Network latency and failures: Every service call adds latency and can fail. You need retries, timeouts, circuit breakers, and bulkheads.
- Data consistency: Each service owns its database, so joins across services are impossible. You must duplicate data or use API composition.
- Operational overhead: Deploying and monitoring dozens of services requires mature CI/CD, container orchestration (e.g., Kubernetes), and observability tools. A small team may drown in YAML.
Comparisons: Monolith vs Modular Monolith vs Microservices
A useful middle ground is the modular monolith. You organize the code into well-defined modules with strict interfaces, but still deploy as one unit. This gives you:
- Clear boundaries for team ownership (each team owns a module).
- Simpler deployment and testing than microservices.
- Easier refactoring later—you can extract a module into a service when needed.
Microservices shine when you have multiple teams that need to scale independently and a strong DevOps culture. But if you are a team of five building a new product, a monolith (or modular monolith) is almost always faster to build and maintain.
Costs and Safety: What to Consider Before Splitting
Splitting a monolith is not a one-time event; it is an ongoing investment. Costs include:
- Engineering time: Extracting a service requires defining APIs, migrating data, and setting up new deployment pipelines.
- Infrastructure: More services mean more compute, more networking, and more monitoring tools.
- Team skills: Developers must learn distributed systems concepts (consistency, idempotency, observability).
To do it safely, follow a strangler fig pattern: incrementally replace parts of the monolith with new services while keeping the overall system working. Start with a low-risk, high-value module (e.g., a notification service) and prove the pattern before scaling the effort.
Alternatives: When Not to Split
If your monolith is still serving users well and the pain points are not severe, consider these alternatives:
- Refactor internally: Improve modularity, reduce coupling, and adopt better testing practices.
- Scale vertically: Buy a bigger server. It is often cheaper than the operational cost of microservices.
- Use a service-oriented architecture (SOA) with larger services: Sometimes called miniservices—larger than microservices but still independently deployable.
Remember that many successful companies run a monolith for years. The goal is not to be microservices; it is to ship software quickly and reliably.
Frequently Asked Questions
What is the main difference between monolith and microservices?
The main difference is deployment and data ownership. A monolith is a single deployable unit with one database. Microservices are multiple independently deployable units, each with its own database and API.
How do I know if my monolith is too big?
There is no strict size limit. Look for symptoms: deployment takes too long, tests are flaky, a small change requires many teams, or scaling one feature forces you to scale everything. If these are frequent, consider modularizing or splitting.
Can I split a monolith without rewriting everything?
Yes, use the strangler fig pattern. Gradually extract one module at a time into a new service, keeping the monolith and new services working together. This reduces risk and allows you to stop at any point.
Is it cheaper to run a monolith than microservices?
Generally, yes. A monolith requires fewer servers, less networking, and simpler monitoring. Microservices add infrastructure and operational costs, so they are only worth it if the scaling or organizational benefits outweigh those costs.
What is a modular monolith?
A modular monolith is a single deployable unit that is internally organized into strong modules with clear interfaces. It gives you some of the maintainability of microservices without the operational complexity.
When should I never split my monolith?
If your team is small (less than 10 developers), your product is early-stage, or you do not have the operational tooling (CI/CD, monitoring) in place, stay monolithic. Splitting prematurely will slow you down.