Skip to content

Practical software architecture · Part 1 of 10

Monolith vs microservices: the trade-offs without the hype

A monolith is one deployable unit, microservices are many. Each has costs. Start simple, split along real boundaries when the pain is clear.

· 2 min read

architecturemicroservices

Architecture debates often treat microservices as a sign of maturity. They are a trade: you buy independence and pay with distribution.

What a monolith gives you

A monolith is one codebase deployed as one unit. A function call is in-process, a database transaction can span the whole operation, and one test run covers everything. It is easy to start, easy to debug and easy to refactor, because the compiler or the tests tell you what broke.

Its limits appear with size: builds and tests get slow, many people touch the same code, and one weak module can take the whole process down.

What microservices give you

Services are deployed independently, scaled independently and can use different technologies. A team can own one service end to end and release it without coordinating with everybody.

What they cost

  • Network calls replace function calls. They are slower and they fail, so you need timeouts, retries and fallbacks.
  • Data is split. There is no cross-service transaction, so you handle consistency with events and compensation.
  • Operations multiply. Every service needs deployment, monitoring, logging and security.
  • Testing and debugging get harder. A request crosses many services, so you need tracing.

A middle path: the modular monolith

Keep one deployable unit but enforce boundaries inside it: separate modules with explicit interfaces and no reaching into each other's tables. You get most of the clarity and can extract a module later if it truly needs to scale or be owned separately.

Ruby
# A module exposes a small interface; callers never touch its internals.
module Billing
  def self.charge(customer_id:, cents:)
    raise ArgumentError, "cents must be positive" unless cents.positive?
    { customer_id: customer_id, cents: cents, status: "charged" }
  end
end

puts Billing.charge(customer_id: 1, cents: 500)

When splitting is justified

  1. A part has very different scaling needs from the rest.
  2. A team boundary is real and the coordination cost is measurable.
  3. A part needs another runtime or strict isolation, for example for security.

Takeaway

Begin with a well-structured monolith, watch where it hurts, and extract services only where the benefit is larger than the operational price.

A knowledge article, drafted with AI assistance and checked with automated tests. It is general background, not a description of my own experience or of any client's work.

Comments

Leave a comment

No account or email needed. Comments appear after review. A one-way hash of your IP address is kept for 30 days to fight spam, then erased.