Microservices Architecture: Choose Boundaries and Timing
Microservices are not merely small services; they are a distributed architecture in which teams can independently deploy and operate business capabilities with clear data ownership. Without sound boundaries and operational readiness, network, data, and observability costs can outweigh deployment benefits.
Define boundaries by business capability, not size
A microservice is an autonomous service responsible for a business capability. Domain-driven design (DDD) subdomains and bounded contexts help locate areas where business rules and language change together. Splitting screens, tables, or code layers into services can increase service count without creating independence.
Ask whether a candidate capability can deploy without another service, own its data, and expose a stable API or message contract. If two services change together, call each other repeatedly, or need to know each other’s internal data structures, the boundary may be wrong. Capabilities that change together may belong in one service or module.
Account for data ownership and consistency
Each service should own its data; other services should not read or write its tables directly. Services can use one physical database server, but sharing schemas and tables makes one team’s change constrain another team’s release. A service can build a local read model from an API or events it receives.
Replicated data may not be immediately consistent. Name the source of truth for each fact and state how much delay a read view can tolerate. A change spanning services may not fit one ACID transaction, so define the workflow steps, retries, compensating actions, and final state. If strong atomicity is essential, keeping the capability inside one boundary may be simpler.
Example: order and delivery boundaries
If order acceptance, pricing and payment rules, and delivery execution have distinct policies and change at different rates, consider separate order and delivery services. Give delivery only the customer identifier and address it needs; do not let it query the full payment history. The delivery service can publish status updates for the order view, while the order service remains the owner of order facts and refund history.
If order and delivery logic always changes together, each change requires several synchronous calls, and one service failure makes the entire transaction fail, splitting them may add little value. Do not target a service count. Draw boundaries around business cohesion and independent deployment.
Prepare the team and platform to operate them
Service boundaries require deployment pipelines, configuration and secret management, service authentication, failure isolation, compatible API and event contracts, and logs, metrics, and distributed tracing. Use a correlation ID to connect one user operation across service logs. Check that teams have the time and skills to build and operate their services end to end, and that shared logging, deployment, and security standards exist. Unlimited language and framework choices can add training, patching, and hiring costs.
Splitting without independent releases, monitoring, and automated recovery can multiply distributed failure points. Plan for network timeouts, delays, and partial success; set timeouts, bounded retries, and resilience policies such as circuit breakers. Evolve service contracts compatibly.
Evaluate a safe path from a monolith
Consider microservices when frequent changes, different scaling needs, clear business boundaries, and autonomous teams justify them, and the operational foundation is ready. A modular monolith can be more efficient for a simple product, a small team, coordinated releases, or tightly coupled consistency needs.
When migration is justified, separate one low-dependency capability with clear value instead of rewriting everything at once. The Strangler Fig approach moves requests gradually while the existing system continues to run; an Anti-Corruption Layer can protect the new boundary from legacy concepts. Plan data migration, dual-write risks, and rollback first. Measure whether release frequency, recovery time, failure spread, and cross-team coordination actually improve.