Blog/Microservice Architecture pattern

Microservice Architecture pattern

Make business services independently deployable and let each service own its contracts and state. Callers communicate through explicit APIs or events.

Context

A business-critical application needs frequent, reliable releases. Small cross-functional teams can own business subdomains and operate what they build. The architecture determines how often those teams can turn a change into a release on their own.

Teams take responsibility for different areas of the business domain.Teams take responsibility for different areas of the business domain.

Problem

How should business subdomains be packaged so teams can deliver at different speeds?

Forces

Small components make it easier to understand changes, test them quickly, and keep one team in charge of a release. Separate workloads may also call for different technology, throughput, or uptime. Closely related operations are easier to trace when they stay local, can avoid network round trips, and can share an ACID transaction. Evaluate a boundary against both sets of constraints.

Solution

Package the subdomains as independently deployable services. Give each subdomain a clear owner and group closely related ones into a service where that fits the workload and the team's responsibilities. Each service exposes an explicit API or event contract and manages its own data. A gateway can route public requests without exposing the application's internal layout.

Teams own services comprising one or more business subdomains.Teams own services comprising one or more business subdomains.

Examples

A booking platform can release its seat-reservation service without redeploying billing. The services communicate using a stable reservation identifier and versioned events.

Fictitious e-commerce application

A storefront supports checkout while separate services own inventory, available credit, and shipping. When an order comes in, the order service coordinates stock and payment decisions with their owners. The shipping service picks up confirmed orders, using its own delivery rules and release cycle.

An example store separates its storefront and backend capabilities into services.An example store separates its storefront and backend capabilities into services.

Show me the code

Trace one order or reservation through the service boundaries in the FTGO example application. Start at the gateway and identify which service owns each write.

Resulting context

Benefits

Each team can change and test a smaller component. Common operations can scale with their own traffic, and one component can adopt a new runtime on its own schedule.

Drawbacks

Remote interactions add latency and failure modes. Workflows can require retries, compensations, and eventually consistent state around service-owned databases.

Issues

Measure how many releases actually require synchronized changes. A service boundary that forces most user-facing changes through several teams may need to move.

Designing a good (monolithic or microservice) architecture with Assemblage

Richardson's Assemblage method starts with business subdomains and their team owners, then evaluates candidate deployable groupings against operational and delivery constraints. Compare the grouping that makes most changes local with the grouping that gives teams the most release independence.

The architecture groups business subdomains into deployable components owned by teams.The architecture groups business subdomains into deployable components owned by teams.

Design pressures that encourage splitting components and other pressures that favor keeping operations local.Design pressures that encourage splitting components and other pressures that favor keeping operations local.

Designing distributed operations

Choose a collaboration pattern for each cross-service operation. A write can use a saga across local transactions. A read can compose API results at request time or use a CQRS projection when joins are expensive.

Patterns for commands and queries that involve multiple data owners.Patterns for commands and queries that involve multiple data owners.

Patterns that address operational and design problems introduced by microservices.Patterns that address operational and design problems introduced by microservices.

Known uses

The reference points to Netflix, Amazon, and eBay as examples of teams moving from a monolith toward distributed services as their product and operational needs changed.

Verify the behavior

Roll one service back while its neighbours remain at the new version. Simulate a downstream outage and check whether the user sees a partial result, a retryable error, or an accepted asynchronous operation. Measure how often changes still cross deployment boundaries.