# Monolith vs microservices

> What splitting a service buys you, what it costs, and the modular monolith in between.

Concept · Requirements & scale · https://levelcode.org/concepts/monolith-vs-microservices

A **monolith** is one deployable application containing all the business logic. **Microservices** split that logic into separately deployed services that communicate over the network, each usually owning its own data.

## What microservices buy

- **Independent deployment.** Teams ship their service without coordinating a release with everyone else.
- **Independent scaling** of hot components.
- **Fault isolation**, if designed for it: a crashing recommendations service needn't crash checkout.
- **Technology freedom** per service.

## What they cost

- **Every call is a network call** that can fail, time out or succeed twice, so you need [timeouts](https://levelcode.org/concepts/timeouts), [retries](https://levelcode.org/concepts/retries-with-backoff) and idempotency everywhere.
- **No transactions across services.** Consistency across them needs [sagas](https://levelcode.org/concepts/saga-pattern) and [outboxes](https://levelcode.org/concepts/transactional-outbox).
- **Operational load:** service discovery, tracing across services, versioned APIs, many pipelines and dashboards.
- **Harder debugging and testing**, because behaviour emerges from many processes.

## The modular monolith

Most of the benefits of good boundaries come from **modules**, not from network hops. A modular monolith keeps one deployable but enforces boundaries inside it: each module owns its tables, exposes a narrow interface, and doesn't reach into others' data. It's fast to build and easy to operate, and a well-separated module can be extracted into a service later if a real need appears.

## When to split

Split a service out when there's a concrete reason: a team that needs to deploy independently, a component with very different scaling or reliability needs, or a security boundary. "Microservices are best practice" isn't a reason. Splitting along the wrong boundaries produces a distributed monolith — all the costs of both. See [when not to add infrastructure](https://levelcode.org/concepts/when-not-to-add-infrastructure).
