Skip to main content
1:1 mock interviews with Sumit, scored on a real hiring rubric.Book a slot →

Microservices vs Monolith: Which Architecture Should You Choose?

A practical comparison of monolithic and microservices architecture: how each works, pros and cons, communication patterns, data ownership, the modular monolith, migration with the strangler fig pattern and how to decide.

Sumit KumarUpdated Oct 11, 20265 min readSystem Design
Microservices vs Monolith: Which Architecture Should You Choose?

Every backend system has to answer an early question: do we build one application, or many small services? A monolith packages all features into a single deployable unit. Microservices split the system into independent services that talk over the network. Both are valid; the right choice depends on your team, your scale and how well you understand your domain.

The two architectures#

Monolith vs microservices architecture: a single deployable application with one database compared with independent services, each with its own database, behind an API gateway

Monolith#

One codebase, one build, one deployment, usually one database. Users, orders, payments and notifications are modules inside the same process and call each other as normal functions.

Java
// Inside a monolith: a plain method call, in the same transaction
@Transactional
public Order placeOrder(Long userId, Cart cart) {
    User user = userService.get(userId);
    Order order = orderRepository.save(new Order(user, cart));
    paymentService.charge(user, order.total());
    inventoryService.reserve(cart.items());
    return order;
}

Microservices#

Each business capability is its own service, with its own codebase, deployment pipeline and database. Services communicate through APIs or messages.

Text
Client → API Gateway → User Service      (users DB)
                     → Order Service     (orders DB)
                     → Payment Service   (payments DB)
                     → Inventory Service (inventory DB)

Side-by-side comparison#

MonolithMicroservices
DeploymentWhole app at onceEach service independently
ScalingScale the whole appScale only the busy services
DataShared database, ACID transactionsDatabase per service, eventual consistency
CommunicationIn-process function calls (fast, reliable)Network calls (slower, can fail)
Tech stackOne language/frameworkEach service can choose
Testing & debuggingSimple, one processNeeds contract tests and distributed tracing
Team ownershipShared codebaseTeams own services end-to-end
Operational overheadLowHigh: service discovery, monitoring, CI/CD per service
Failure impactA crash can take down everythingFailures can be isolated (with good design)

Why teams choose a monolith#

  • Speed early on: one repo, one deploy, easy refactoring across modules.
  • Simple data consistency: a single database transaction covers the whole operation. See ACID transactions.
  • Easy debugging: one stack trace, one log stream, one profiler.
  • Cheaper to run: fewer servers, less infrastructure.
  • Performance: no network latency between modules.

Shopify, Stack Overflow and Basecamp have run very large businesses on well-structured monoliths.

Why teams choose microservices#

  • Independent deployments: the payments team can ship ten times a day without coordinating with search.
  • Targeted scaling: scale the video encoder to 200 instances while the profile service runs on 3.
  • Fault isolation: a bug in recommendations shouldn't break checkout.
  • Team autonomy: clear ownership boundaries for large organisations (Conway's law).
  • Technology freedom: use Python for ML, Go for high-throughput APIs, Java for core business logic.

The hidden costs of microservices#

The distributed monolith

If your services share a database, must be deployed together, or call each other in long synchronous chains, you have all the costs of microservices with none of the benefits. This is the most common microservices failure.

  • Network failures: every call can time out. You need timeouts, retries with backoff, and circuit breakers.
  • Distributed data: no cross-service transactions. You need sagas, outbox patterns and idempotent consumers.
  • Observability: a single request spans many services, so you need centralised logs, metrics and distributed tracing (OpenTelemetry).
  • Infrastructure: containers, Kubernetes, service discovery, API gateways, per-service pipelines.
  • Versioning: API changes must stay backward compatible.

How microservices communicate#

StyleExamplesUse for
Synchronous request/responseREST, gRPCQueries that need an immediate answer
Asynchronous eventsKafka, RabbitMQ, SQSNotifying other services that something happened
Text
Order Service ──"OrderPlaced" event──▶ Kafka ──▶ Payment Service
                                            ├──▶ Inventory Service
                                            └──▶ Email Service

Events decouple services: the order service doesn't need to know who reacts to an order. Learn more in message queues: Kafka vs RabbitMQ.

Handling a multi-service transaction: the saga pattern#

Text
1. Order Service:     create order (PENDING)   → emits OrderCreated
2. Payment Service:   charge card              → emits PaymentCompleted   (or PaymentFailed)
3. Inventory Service: reserve stock            → emits StockReserved      (or OutOfStock)
4. Order Service:     mark CONFIRMED

On failure, run compensating actions in reverse:
   OutOfStock → refund payment → cancel order

The middle ground: a modular monolith#

A modular monolith is a single deployable application with strict internal boundaries: each module owns its tables, exposes a clear interface, and other modules can't reach into its internals.

Text
src/
  orders/      api/  internal/  (owns orders_* tables)
  payments/    api/  internal/  (owns payments_* tables)
  inventory/   api/  internal/
  shared/      (only truly shared utilities)

You get the simplicity of one deployment today, and if a module later needs to scale or be owned by a separate team, it's already shaped like a service and can be extracted.

Enforce the boundaries

Tools like ArchUnit (Java), Spring Modulith, or import-linting rules (eslint-plugin-boundaries, import-linter for Python) fail the build when one module reaches into another's internals.

Migrating: the strangler fig pattern#

Never rewrite a working monolith from scratch. Instead, grow new services around it, like a strangler fig vine:

  1. Put a routing layer (API gateway or proxy) in front of the monolith.
  2. Pick one well-bounded capability, such as notifications.
  3. Build it as a new service and route its traffic there.
  4. Migrate its data and remove the old code from the monolith.
  5. Repeat for the next capability, one slice at a time.

How to decide#

Choose a (modular) monolith if…Consider microservices if…
You're a startup or small team (under ~20 engineers)Many teams are blocked by each other's releases
The domain and boundaries are still changingBoundaries are stable and well understood
Load is moderate and fairly uniformParts of the system need very different scaling
You lack DevOps and observability maturityYou already have CI/CD, containers, tracing and on-call

Scaling is often the deciding factor; read vertical vs horizontal scaling and the CAP theorem next. For a hands-on start, see the Spring Boot REST API guide.

Key takeaways#

  • A monolith is one deployable unit; microservices are independently deployable services with their own data.
  • Monoliths are simpler, faster to build and easier to keep consistent; microservices offer independent deploys, targeted scaling and team autonomy.
  • Microservices bring network failures, distributed data and heavy operational costs.
  • A modular monolith gives clean boundaries without the distributed-system tax.
  • Start simple, and extract services gradually with the strangler fig pattern when real pain appears.