One shop, one application A shopper checks out. In a monolith, one application holds orders, payments and stock. It is built, tested and deployed as one unit, and it keeps everything in one database.
Checkout calls the payment code and the stock code as ordinary function calls in the same process. Those calls take nanoseconds and never get lost on a network.
A monolith is simple, until many teams share it A monolith is easy to run: one pipeline, one log stream, one thing to debug. Changing orders and stock together is a single commit and a single database transaction.
The pain comes with growth. Many teams merge into one codebase and wait for one release train. A bug in one area can take the whole app down. To scale the busy stock check you scale the entire app.
Key idea Most problems blamed on "the monolith" are really missing boundaries inside it. Splitting the deploy does not fix tangled code by itself.
A modular monolith draws the lines inside A modular monolith is still one deploy unit, but it is split into modules with clear boundaries. Orders, payments and stock each own their tables, and other modules call them only through a public interface, never by reading their tables.
You keep fast in-process calls and one deploy, and you gain boundaries that a team can own. If one module later needs its own service, the cut line already exists.
Key idea Enforce the boundaries with tooling, for example architecture tests or build rules that forbid one module importing another's internals.
Microservices split the deploy unit With microservices, orders, payments and stock become separate services. Each has its own code repository or folder, its own pipeline and its own team. An API gateway routes requests by path.
Team B can ship payments five times a day without waiting for anyone. Stock gets busy at sale time and scales to 10 replicas while payments stays at 2. A crash in stock does not have to take checkout down.
Key idea The gains are organizational as much as technical: independent deploys, independent scaling and clear ownership.
Each service owns its data Each service keeps its own database, or at least its own schema that no one else touches. Others get the data through its API or its events.
If services share one database, every table becomes a hidden API. Renaming a column in stock breaks orders. Teams have to deploy together and coordinate migrations, and you are back to a monolith, but with network calls.
Key idea A shared database is the most common way microservices end up coupled. Check which services connect to which database host before calling the system "independent".
Synchronous call chains multiply latency and failure Checkout now calls payments, which calls stock, over the network. Each hop adds latency and serialization, and can time out. Latency adds up along the chain. Availability multiplies: five services at 99.9% each, all needed, give about 99.5% for the whole request.
Tail latency gets worse too. If one call in a hundred is slow and a request needs ten calls, about one request in ten hits a slow call.
Watch out Keep chains short, call in parallel where you can, and use events for work that need not finish before the reply. Put timeouts, retries with backoff and circuit breakers on every hop.
No transaction spans services In the monolith, "take payment and reserve stock" was one transaction. Now the two live in different databases, and nothing commits both at once.
You replace the transaction with a saga: a series of local steps, each publishing an event, with compensating steps (refund, release stock) when a later step fails. Data is eventually consistent, and a report that joins orders and payments now needs a copy of both in one place.
Watch out If two pieces of data must always change together, they probably belong in the same service.
Observability, versioning and operations cost more One checkout now touches three services. To find why it was slow you need distributed tracing and a request id passed along every hop. Logs from all services must land in one place.
Services deploy on their own, so APIs must stay backward compatible: add fields, do not rename or remove them until every caller has moved. And every service needs a pipeline, dashboards, alerts, security patches and an owner on call.
Watch out Have tracing, central logs, and a template for new services ready before you split. Without them, microservices are hard to debug.
Migrate with a strangler fig, one piece at a time Big-bang rewrites rarely go well. With the strangler fig pattern, you put a proxy or API gateway in front of the monolith first. Then you build one capability, say payments, as a new service and route only its paths there.
Everything else still goes to the monolith. When the new service works, you delete that code from the monolith and pick the next piece. At every point the system runs and can be rolled back by changing a route.
Key idea Move the data along with the code. A new service that still reads the monolith's tables has not really been split out.
Often, a monolith is the right choice A small team, a new product whose boundaries are still unclear, or a system without very different scaling needs is usually better off as a well-structured monolith. Splitting too early fixes wrong boundaries in place, and moving a boundary between services is far harder than moving it between modules.
Split when there is a clear pressure: teams blocking each other on releases, one part that needs very different scaling or reliability, or a part with different security or compliance needs.
Watch out Start with a modular monolith, measure where it hurts, and split out the piece with the strongest reason first.
Pay for distribution only where it pays you back A monolith gives simple deploys, fast calls and one transaction. A modular monolith adds the boundaries teams need. Microservices add independent deploys, scaling and ownership, and charge you in network calls, split data, tracing, API versioning and operations.
Give each service its own data, keep call chains short, and migrate step by step with a strangler fig when the pressure is real.