Skip to content

Monolith vs. microservices

Introduction

A monolith puts all features in one program deployed together; microservices split features into many small programs that are deployed independently and talk to each other.

Why think it through

Monolith Microservices
Getting started Fast Slow; a lot of infrastructure comes first
Deployment One deploy Many services, each deployed on its own
Troubleshooting One set of logs Cross-service tracing (see logging)
Data consistency One database transaction Ordinary transactions do not span services
Team size Fits a small team Fits several independent teams

Microservices mainly solve organization and scale problems (many teams waiting on each other, one part needing independent scale-out), not “technical modernity”.

How to do it

  1. Start with a modular monolith: one program, but split internally by business (orders, users, payments); modules talk only through clear interfaces and each owns its tables.
  2. Split only when there is a real signal: a module needs independent scale-out, teams block each other, or a module needs a different stack.
  3. When splitting, take one module at a time and start with the clearest boundary; add timeouts and retries to service calls, pair retries with idempotency; use a message queue for async coordination; automate deploy with CI/CD.

Component comparison

Monolith

Hand-rolledOpen sourceOpsLow

All features are written in one program, developed together and deployed together.

Best forMost projects with a small team and a business still in exploration.

Avoid whenThe team is already large and multiple groups need to release their own features independently.

Pros

Simplest to develop, debug, and deploy, and one server can run it

Features call each other directly, with no network communication hassles

Transaction consistency is easy to guarantee

Cons

Code gets longer and messier, and without constraints modules entangle with each other

Any small change requires a full re-release

Cannot scale only one part independently

Modular monolith

Hand-rolledOpen sourceOpsLow

Still one program deployed together, but internally divided clearly into modules by business area, and modules talk only through agreed entry points.

Best forProjects whose business is growing more complex and whose team is mid-sized.

Avoid whenThe project is very small, and dividing into modules just adds needless complexity.

Pros

Keeps the deployment simplicity of a monolith while having clear code boundaries

Easier to split a module into an independent service later

No need to pay the infrastructure cost of microservices

Cons

Boundaries rely on team discipline, and without tool or review checks they gradually erode

All modules still share one release and cannot be released independently

Someone must plan upfront how to divide the modules

Microservices

Hand-rolledPay-as-you-goOpsHigh

Split the system into many small programs, each developed and deployed independently and calling each other over the network.

Best forMature products with very large teams where each business line needs to evolve independently.

Avoid whenThe team has only a few people, or the business model is still changing frequently.

Pros

Each team can release on its own, and can also scale one service on its own

One service failing does not necessarily take down the rest

Different services can each choose their own technology stack

Cons

Discovery, monitoring, and tracing all have to be set up, so operations are heavier

Changing the same record across services makes consistency hard

One call spans several services, so finding the fault takes longer

Serverless / cloud functions

Cloud-managedPay-as-you-goOpsLow

Break code into individual functions run by the cloud platform, executing only when there are requests, with no servers to manage.

Best forAPIs with fluctuating traffic, and small features such as scheduled tasks and file processing.

Avoid whenCore services that must run for long periods and need stable latency.

Pros

You do not manage servers, and the cost is very low when traffic is small

When traffic jumps, the platform scales up on its own

A good fit for short, scattered tasks that are triggered by events

Cons

The first call after sitting idle has a cold start

It is tied to a specific cloud, and local debugging is inconvenient

Runtime and memory have caps, so long tasks do not fit

Checklist

  • New projects default to a modular monolith
  • Module boundaries are clear; modules do not read or write each other’s tables
  • Splitting into microservices has a concrete reason (scale-out, teams, stack), not “because it is popular”
  • Before splitting, log tracing, automated deploy, and monitoring are already in place
  • Each microservice owns its own data and does not share a database