Software Architecture

Microservices: Service Boundaries, Independent Deployability and the Real Cost

Intermediate11 min readUpdated

Microservices trade internal complexity for distributed complexity, and the trade only pays when the organisation needs independent delivery. This guide defines what the style genuinely requires, shows how to find boundaries that survive contact with real features, weighs communication styles, and gives a realistic account of the operational bill and the migration path out of a monolith.

What you will learn

  • State the properties a system must have before it can honestly be called microservices
  • Find service boundaries from business capabilities rather than from technical layers
  • Choose between synchronous and event-driven communication for a given interaction
  • Estimate the operational investment a microservice platform demands before committing to it
  • Plan an incremental extraction from a monolith using the strangler fig approach

Microservices are usually introduced as a way of building software and are better understood as a way of organising delivery. The technical description — small services, each in its own process, communicating over the network — is the easy part and describes plenty of systems that get no benefit from it. What makes the style worthwhile is a property that has nothing to do with size: any one service can be changed, tested, released and rolled back without coordinating with the teams that own the others.

That property is expensive. It requires automated pipelines per service, tolerance of partial failure in every caller, observability that spans processes, and a data design in which no two services touch the same rows. Teams that adopt the vocabulary without paying for the property end up with a distributed monolith: all the network hops of microservices, all the release coordination of a monolith, and a debugging experience worse than either. This guide is about earning the property honestly, and about the cases where a well-modularised single deployable is the better engineering answer.

What the style actually requires

Five commitments separate microservices from "several applications that talk to each other".

One deployable unit per service, released on its own schedule. If shipping a change to the pricing service requires a synchronised release of the catalogue service, the two are a single unit of change wearing two containers. Independent releasability is the acid test and the thing to measure.

Private data. A service owns its persistent state and is the only process that reads or writes it. Other services see that state only through the service's interface or through data it deliberately publishes. This is the rule most often broken and the one whose violation is hardest to undo.

A contract that outlives its implementation. Consumers depend on a published interface — an HTTP API, a message schema — not on a shared library of entity classes. Backward-compatible evolution is a design requirement, not an aspiration.

Failure isolation. Every remote call may be slow, fail or return something unexpected. Callers set timeouts, cap concurrency and degrade gracefully. Without this, a system of twelve services with 99.9 % availability each is less reliable than the monolith it replaced.

A team that owns it end to end. The same people design, build, deploy and support the service. Conway's law makes this less a preference than a prediction: an organisation whose teams are split by technical layer will produce services split by technical layer, whatever the architecture diagram says.

Finding boundaries that hold

Bad boundaries are the defining failure of microservice projects, and they are almost always drawn along technical lines: a "database service", a "validation service", an "orchestration service". Each of these participates in every use case, so every feature touches every service and nothing can be released alone.

Boundaries that hold are drawn around business capabilities — things the business does that have a name, an owner and a lifecycle of their own. Ordering, pricing, inventory, invoicing, shipment tracking, customer identity. The vocabulary and modelling technique for this comes from domain-driven design, where a bounded context is exactly the unit that a service should implement.

Three practical tests help judge a candidate boundary:

TestQuestionWhat a bad answer looks like
Change cohesionWhen a typical feature arrives, how many services change?Nearly all of them, every time
Data ownershipCan this service answer its main queries from its own store?It needs a join across two other services
VocabularyDo the terms inside mean one thing consistently?"Order" means four different things in one service

The change-cohesion test is the most informative because it is measurable after the fact. Take the last twenty completed features and count how many services each touched. A healthy distribution has most features landing in one or two services. If the median is five, the boundaries are wrong and adding more services will make it worse.

Boundaries also have a time dimension. The right split for a product with 30 000 users is rarely the right split at 3 million, and services do get merged. Treat a boundary as a hypothesis with an expiry date rather than a permanent decision, and keep the cost of merging two services low by keeping their interfaces narrow.

Data per service, and what to do about queries

Giving each service its own schema is straightforward until the first report needs data from four of them. The available answers are all trade-offs, and choosing badly here is what pushes teams back to a shared database.

API composition. A caller — often the gateway or a dedicated aggregator — queries several services and joins in memory. Simple, correct, and fine for a handful of records. It degrades badly for anything that needs filtering or sorting across services, because you cannot page a join you compute yourself.

Replicated read models. Each service publishes events when its data changes; interested services keep a local, denormalised copy shaped for their queries. Reads become fast and local; the cost is eventual consistency and the code to maintain the projection. This is the general form of the CQRS pattern described in the microservice design patterns guide.

A separate analytical store. Reporting and business intelligence should not run against operational services at all. Stream changes into a warehouse or lake and let analysts join to their hearts' content there.

The rule that keeps this manageable: a service may publish its data, but it never lets another service reach into its storage. A read replica exposed to other teams is a shared database with extra steps — the schema becomes public, and it freezes.

Communication styles

Two families, each appropriate for different interactions.

Synchronous request/response (HTTP or gRPC) is the right choice when the caller cannot continue without the answer: checking whether a customer exists before creating an order, validating a token. It is simple to reason about and easy to trace. Its danger is temporal coupling — the caller's availability becomes the product of every service in the chain — and latency that accumulates hop by hop. Keep chains shallow; two levels deep is manageable, five is a distributed stack trace waiting to time out.

Asynchronous events publish a fact and let interested parties react. "OrderPlaced" is emitted once; inventory, billing and notifications each do their part on their own schedule. The publisher does not know or care who listens, so adding a consumer needs no change upstream, and a consumer being down delays work rather than failing it. The costs are eventual consistency, harder end-to-end debugging and the need for consumers to handle duplicate deliveries. The mechanics of brokers, ordering and delivery guarantees are covered in messaging patterns and guarantees.

A useful heuristic: use synchronous calls for queries and asynchronous events for state changes that propagate. Commands that must be confirmed to a waiting user stay synchronous; everything the user does not need to wait for becomes an event.

// Synchronous: the order cannot be priced without this answer.
CustomerTier tier = customerClient.tierFor(customerId);   // timeout: 300 ms, fallback: STANDARD

// Asynchronous: nobody waits for stock, invoicing or email.
events.publish(new OrderPlaced(order.id(), order.lines(), order.total(), Instant.now()));

Whatever the style, versioning matters more than protocol choice. Add fields, never repurpose them; tolerate unknown fields on the consumer side; and keep an old message shape readable for at least as long as the slowest consumer takes to upgrade.

The operational bill

The engineering effort a microservice platform demands is routinely underestimated because it is invisible in the architecture diagram. Before committing, budget for all of it.

  • A pipeline per service. Build, test, security scan, deploy to each environment, roll back. Multiply by the number of services; if creating a new service takes a week of pipeline plumbing, teams will avoid creating services and stuff features into existing ones. This is why continuous delivery pipelines are a prerequisite, not a follow-up project.
  • Distributed tracing and correlated logs. Without a trace ID propagated through every hop, diagnosing "the checkout is slow" means reading twelve log files by hand.
  • Centralised metrics and alerting per service, with service level objectives that describe user-visible behaviour rather than CPU.
  • Runtime platform. Container orchestration, service discovery, secrets management, certificate rotation, network policy.
  • Contract testing. Consumer-driven contract tests catch the incompatible change before it reaches an environment where it costs a day to diagnose.
  • On-call rotation and runbooks per team, because the team that ships is the team that gets paged.

A rough sanity check: if the organisation cannot deploy its current monolith to production on demand, in under an hour, with automated tests it trusts, it is not ready to operate fifteen services. Microservices amplify the maturity of a delivery process; they do not supply it.

When a monolith is the right answer

A single deployable is the correct choice more often than conference talks suggest. It is right when the team is small enough that everyone can attend one stand-up, when the domain is not yet understood well enough to draw stable boundaries, when the product's traffic scales uniformly rather than in hot spots, and when transactional consistency across the whole model is a genuine requirement rather than a habit.

The version worth aiming for is the modular monolith: one process, one deployment, but internal modules with enforced boundaries. Each module has its own package tree, its own schema (or at least its own tables with no cross-module foreign keys), a public interface of a handful of types, and a build-time check that fails the build when a module reaches into another's internals. Java's module system, ArchUnit rules or simply separate build modules all work.

ConcernModular monolithMicroservices
DeploymentOne pipeline, one artefactOne pipeline per service
Refactoring across boundariesCompiler-assisted, minutesCoordinated releases, weeks
ConsistencyLocal transactionsSagas and eventual consistency
ScalingWhole application togetherPer service
Failure blast radiusWhole processOne service, if isolated
Team autonomyShared release trainIndependent
DebuggingOne stack traceDistributed trace

The modular monolith is also the honest starting point for a system you intend to split later, because the modules tell you where the seams are. Splitting a well-modularised monolith is mechanical; splitting a tangled one is archaeology.

Migrating with the strangler fig

Rewrites of large systems fail for well-understood reasons: the business keeps changing the old system while the new one is built, and the cutover is a single enormous risk. The strangler fig approach avoids both by extracting one capability at a time, routing traffic to the new implementation, and letting the old system shrink until it can be removed.

  1. Put a routing layer in front

    Place a gateway or reverse proxy between clients and the monolith so that traffic can be redirected per path without changing clients. See API management and gateways.
  2. Choose a capability worth extracting

    Pick one with a clear boundary, real pain (it changes often, or scales differently), and limited data entanglement. Do not start with the hardest or the most central.
  3. Carve out the data first

    Identify the tables the capability owns, remove cross-schema joins and foreign keys from the monolith, and replace them with calls or published events. This is usually the longest step and the one that determines success.
  4. Build the service and run both

    Implement the new service, then run it alongside the old code — shadow traffic, or write to both and compare — until behaviour matches.
  5. Switch traffic, then delete

    Move the route, watch the metrics, keep the rollback available for a week, then delete the old code. Skipping the deletion is how organisations end up maintaining two implementations forever.

Track two numbers throughout: the share of traffic served by extracted services, and the number of features still requiring a monolith change. If the second is not falling, the extraction is producing services without producing autonomy.

Common mistakes

Splitting by technical layer. A "UI service", a "business service" and a "data service" recreate the layers of a single application across the network, guaranteeing that every feature touches all three.

Starting with too many services. Teams that begin a greenfield product with twenty services are guessing at boundaries before the domain is understood. Start with two or three coarse services, or one modular monolith, and split when a specific pressure demands it.

Shared libraries containing domain logic. A common JAR with the Order entity in it couples every service to one release cycle. Share utilities if you must; never share the model.

Synchronous chains for everything. Five services in a request path multiply latency and divide availability. Push work into events wherever the user does not need to wait.

No versioning discipline. Renaming a JSON field breaks consumers you have never met. Additive change only, with explicit deprecation windows.

Ignoring the platform bill. Deciding on microservices without funding pipelines, tracing and on-call produces services that nobody can operate and everyone is afraid to deploy.

Key takeaways

  • The defining property of microservices is independent deployability; if services must be released together, the distribution buys nothing and costs a great deal.
  • Draw boundaries around business capabilities and validate them by counting how many services a typical feature touches.
  • Each service owns its data privately; cross-service queries are answered by composition, replicated read models or a separate analytical store, never by a shared schema.
  • Use synchronous calls where the caller needs an answer and events for state changes that propagate, and treat interface versioning as a first-class design concern.
  • The operational investment — pipeline per service, tracing, metrics, contract tests, on-call — is the real cost and must be funded before the first split.
  • A modular monolith delivers most of the design benefit without distributed complexity, and is the best starting point for a future extraction by strangler fig.

Sources and further reading

Frequently asked questions

How small should a microservice be?
Size is the wrong measure. A service should own one business capability completely, including its data, and be small enough that the team responsible can rewrite it in a few weeks if they must. Counting lines of code or insisting on a maximum file count produces services that cannot answer a question without calling four neighbours, which is far worse than a service that happens to be large.
Can several microservices share one database?
They can technically, and the result is a distributed monolith. Any schema change becomes a coordinated release, one service's slow query starves another, and nobody can reason about who writes what. If two services genuinely need the same table, that is strong evidence they are one service. Share data through published interfaces or replicated read models instead.
Do microservices make a system faster?
Almost never at the level of a single request. Splitting an in-process method call into a network call adds serialisation, transport and failure handling — typically a millisecond or more each time. What microservices buy is scaling components independently, so the three endpoints that consume most CPU can be given more capacity without paying for the whole application, and delivery speed for teams that no longer queue behind each other.
Is a modular monolith a step backwards?
It is often the correct destination. A single deployable with strictly enforced module boundaries, separate schemas per module and no cross-module SQL delivers most of the design benefit with none of the distributed cost. It also leaves the option open: modules with clean boundaries can be extracted later when a specific pressure — independent scaling, separate release cadence, different technology — justifies it.