Microservices are often introduced with the promise of independence: each service has a clear responsibility, can evolve independently, and can scale according to its own needs.
But what does that independence cost when routine operations depend on data owned by several services? If displaying a page requires multiple APIs, recording a change requires coordination across databases, and releasing a feature always involves several teams, separating services has not resolved those dependencies.
Using a general online store example, this article explores the problems data dependencies can create, which solutions address each kind of dependency, and when service boundaries deserve another look.
Data Relationships Are Normal
Customers place orders, orders contain products, and shipments belong to orders. These relationships do not, by themselves, make microservices an unsuitable choice.
What matters is why services need each other and what guarantees those interactions require. We should distinguish three kinds of dependency:
| Dependency | Example |
|---|---|
| Reading data | Displaying a customer's name beside an order |
| Enforcing a business rule | Preventing sales beyond available inventory |
| Making changes | Modifying several services to introduce one feature |
These problems do not share a single solution. A dedicated read model may simplify order listings, but it does not independently enforce inventory rules.
Boundaries should reflect business capabilities and domain models. Two different tables do not automatically justify two services. A concept such as “customer” may also have different representations in different contexts: shipping and customer support do not necessarily need the same information. Microsoft's guide to domain analysis
A Simple Join Becomes Multiple Requests
Suppose an order listing must display the order number, customer name, and shipping status. If the data sits behind three service boundaries, one approach is to retrieve and combine their responses.
This is known as API Composition. It can work well for limited datasets, but joining large result sets in memory can become expensive. The API Composition pattern
A straightforward implementation might retrieve the orders and then request the customer name separately for each order. In a hypothetical list of 20 orders, that choice could introduce 20 additional calls.
Fetching customer information in batches can reduce the number of requests. We still need to decide how to handle response sizes, timeouts, and incomplete results.
Filtering and pagination also become more complicated. To find orders from customers in a particular city, retrieving one page of orders and filtering that page by city does not necessarily produce correct pagination over the full matching result set. We need a way to identify the matching records or a suitable read model for the query.
Data Dependencies Can Become Availability Dependencies
If a page depends on three services, a slow response or failure in any required dependency can affect the final result.
Running independent requests in parallel can reduce sequential waiting time, but the dependencies remain. We still need an explicit decision: if shipping information is unavailable, should the whole page fail, or should it display the orders without that information?
An aggregation layer can simplify client interactions, but it needs capacity, failure handling, and monitoring of its own. Placing the operation behind one endpoint does not remove its underlying dependencies. Microsoft's Gateway Aggregation pattern
Individual service health is therefore an incomplete measure of the user experience. We need to examine the full request path and its behavior when dependencies are degraded.
Reading Data Is Different from Enforcing a Business Rule
Displaying a customer name and deciding whether inventory can be allocated have different correctness requirements.
Suppose the order service reads the available inventory and then confirms an order. Another request may consume that inventory between those two actions. Reading a recent value does not reserve it.
The service that owns the allocation rule should make the reservation decision with appropriate concurrency control. The order service can receive the reservation outcome and advance its workflow accordingly.
In DDD, an aggregate defines a consistency boundary: it contains the data and behavior needed to preserve transactional invariants. An aggregate does not automatically need to become a separate microservice. Consistency boundaries in Tactical DDD
If several changes truly must be atomic, separating them deserves careful evaluation. A local transaction in the order database does not, by itself, make an update in the inventory database atomic with it.
For workflows that can temporarily remain incomplete, coordination and recovery rules may be appropriate. First, however, we must establish which intermediate states the business accepts and which rules must never be violated.
Copying Data Moves the Dependency to Synchronization
To reduce calls, a service can maintain a local copy of the subset of another service's data that it needs.
This can reduce synchronous dependencies during reads, but it requires clear ownership, change contracts, and synchronization. If the local copy falls behind its source, we need to know which decisions can still safely use it. Microsoft's data considerations for microservices
Copied values can also have different meanings. In our order example:
- A customer's current name in an order listing might come from a local copy that receives updates.
- The shipping address selected for a particular order may need to remain unchanged when the customer later updates their profile.
- The agreed price on an order should not change whenever the product's current price changes.
These are modeling decisions. A value may represent the source's current state, or it may be part of the historical record of a particular operation.
How Can a Dedicated Read Model Help Reporting?
When the main requirement is repeatedly combining data for display or reporting, we can build a projection: a derived model containing the information needed by those queries.
For example, order, customer, and shipment summaries could be consolidated into a read model so each request does not have to assemble them again.
This can simplify queries, but it adds the cost of maintaining and updating the model. An asynchronously updated model can lag behind its sources. Acceptable staleness, rebuild procedures, and detection of stalled synchronization must be explicit. Microsoft's Materialized View pattern
A read model answers questions efficiently. If a critical business rule requires authoritative, current state, a fast projection alone is insufficient grounds for using it to make the final decision.
What Changes with a Shared Database?
Directly reading another service's tables is a simple way to obtain data. It may make queries easier, but it couples the consumer to another service's storage structure.
Schema changes can then require coordination across services, and ownership may become unclear. Sharing a physical database server is different from sharing tables: services can use the same server while maintaining separate ownership and access boundaries. Microsoft's guidance on shared data
Sharing tables should be a deliberate choice with understood costs. Using them to bypass service contracts throughout the system reduces the independence those boundaries were intended to provide.
Separate Deployments Do Not Guarantee Independent Change
Each service may have its own executable and deployment pipeline while releasing a feature still requires coordinated changes and deployment across several services.
Breaking contract changes, excessive sharing of models, and splitting cohesive behavior across services can create this dependency. Backward-compatible contracts address part of the problem, but they do not replace appropriate boundaries.
Chatty interactions and a recurring need for coordinated deployment are reasons to revisit the design. Sometimes merging two services or moving a responsibility is a better choice. Microsoft's guide to identifying microservice boundaries
Communication alone is not evidence of a bad boundary. We need to understand how frequent the interaction is and how tightly it couples changes.
The Cost Goes Beyond Running More Servers
Distributing a system also makes diagnosing failures more involved. Understanding one failed operation may require logs from several services, message state, and the timing of individual requests.
Automated deployment, monitoring, failure handling, and data consistency are part of the architectural cost. That effort needs to be justified by benefits such as independent feature evolution, team autonomy, or required scalability. Martin Fowler's Microservice Premium
Evaluation should therefore include the cost of changing a feature and the time needed to diagnose and recover from failure, alongside throughput.
Two options in this discussion deserve a closer look. CQRS and separate read models can simplify queries while introducing synchronization work. For a business operation that spans several services, orchestration, outbox, and sagas help track partial progress and recovery, with limits that the design must account for.
Choose a Solution Based on the Dependency
| Problem | Option to consider | Cost or limitation |
|---|---|---|
| Combining limited data for display | API Composition and batch retrieval | Runtime dependencies and incomplete responses |
| Frequent queries combining several sources | A dedicated read model | Synchronization, lag, and maintenance of derived data |
| Reference data that tolerates staleness | A limited local copy with clear ownership | Change propagation and freshness management |
| A critical business rule | Keep the decision and required data within the rule owner's boundary | Reconsidering responsibilities and concurrency control |
| Changes spanning multiple services | Orchestration or a saga suited to the workflow | Intermediate states, compensation, and recovery |
| Frequent joint changes and excessive communication | Revisit boundaries or consolidate some services | Migration effort and less deployment separation |
Sagas and outboxes manage some consequences of distribution. Their presence does not establish that the current decomposition is appropriate. Before adding more coordination, examine whether responsibilities that are too tightly coupled have been separated.
When Is a Modular Monolith a Reasonable Choice?
If domain boundaries are still unclear, changes frequently span components, or independent scaling and deployment are unnecessary, a single application with explicit modules is worth considering.
Logical boundaries, data ownership, and contracts between modules still matter in a modular monolith. Running in one process does not automatically make the code modular.
A potential advantage is that boundaries can be reconsidered before adding network and distributed operations costs. A later move to microservices is still neither automatic nor free; it depends on the quality of modularity and the dependencies that develop. Fowler's Monolith First perspective
Questions to Ask Before Splitting
For each proposed boundary, consider:
- What data does this component need from other components to perform its main work?
- Is the dependency for display, or for making decisions and changes?
- How much latency or data staleness is acceptable?
- Which invariant must be preserved within a transaction?
- What behavior is expected when a dependency is unavailable?
- Can this capability evolve and be released without simultaneous changes to several services?
- Which specific cost does the benefit of separation justify?
Choose boundaries that make the required coordination manageable and provide the independence the system actually needs in development and operation.