Microservices

From WikiTech, the encyclopedia of technology

Concept · Software Engineering & Architecture · 4 min read · 754 words · Updated

Microservices
Concept
TypeDistributed application architecture
Main ideaIndependently deployable services around capabilities
CommunicationAPIs, messaging and events
Common concernsReliability, observability, data ownership
AlternativeModular monolith

Microservices is an architectural style in which an application is divided into relatively small services that communicate through explicit interfaces. Each service is responsible for a business capability or a clearly defined part of the system. Services can often be developed, deployed and scaled independently, but this independence comes with the complexity of distributed communication, data consistency and operational coordination.[1]

Service boundaries and domain modelling

A good service boundary reflects a cohesive responsibility. Services should own a meaningful capability and expose a stable interface, rather than being split mechanically by individual database tables or source-code folders. Domain modelling helps identify which concepts belong together and which rules should be enforced within one service. Poor boundaries create chatty systems where a single user action requires many network calls and coordinated changes across several teams.

Independence is not absolute. Services share infrastructure, security policies and business workflows. They need compatible API versions, clear ownership and a process for changing contracts safely. An API should describe its data model, error behaviour, authentication requirements and compatibility policy. Consumers should not depend on undocumented details of another service's database or internal code.

Communication patterns

Services communicate synchronously through request-response APIs or asynchronously through messages and events. Synchronous calls are easy to understand but introduce latency and runtime dependencies: if one service is unavailable, callers may fail or wait. Asynchronous messaging can decouple producers and consumers, but it introduces delivery guarantees, ordering questions, duplicate messages and eventual consistency.

Retries, timeouts and circuit breakers help manage transient failures, but each must be designed around operation semantics. A request may time out after the server has already completed it, so retrying a non-idempotent action can create duplicates. Idempotency keys and deduplication are important when services process operations that must not be repeated accidentally.

Data ownership and consistency

Each service commonly owns its data store or its logical data boundary. This reduces direct coupling, but it makes cross-service queries and transactions more difficult. A workflow that updates multiple services may use a saga: a sequence of local transactions with compensating actions if a later step fails. This is not the same as a single ACID transaction, and compensation may be a business action rather than a literal rollback.

Event-driven designs can maintain read models for queries, but those views may lag behind the source service. Users and developers need to understand where eventual consistency is acceptable and where a stronger guarantee is required. The CAP theorem helps frame some partition trade-offs, but real design decisions must also account for latency, recovery and data correctness.

Deployment and operations

Independent deployment requires automation. Teams need repeatable builds, container images, configuration management, secrets, health checks and observability. Docker can package services, while Kubernetes can schedule them across a cluster. Neither tool automatically creates good service boundaries or reliable workflows. Distributed tracing, structured logs and service-level indicators help reveal failures that cross multiple components.

A microservice platform also increases the number of things to operate: services, pipelines, databases, queues, certificates, dashboards and access policies. Small teams can become overwhelmed if they adopt the style before they have a clear need. A modular monolith can preserve internal boundaries while avoiding network and deployment complexity.

When microservices are appropriate

Microservices are most useful when a system has distinct domains, multiple teams need independent release cycles, or particular components require different scaling and reliability profiles. They are less attractive when the domain is still changing rapidly, the team is small or the system has only a few tightly coupled workflows. The architecture should solve a measured organisational or technical problem rather than serve as a default badge of modernity.

Further engineering considerations

Observability, resilience and organisational cost

A distributed service can fail in ways that are difficult to reproduce on a developer's computer. A request may cross several services, each with its own latency, logs and failure modes. Observability combines structured logs, metrics and distributed traces so operators can follow a request across boundaries. Correlation identifiers help connect events, while service-level objectives translate user expectations into measurable reliability targets. These practices should be designed alongside the architecture rather than added only after an outage.

Resilience patterns such as timeouts, bounded retries, circuit breakers and queues can reduce the effect of temporary failures, but they must be applied carefully. Unbounded retries can amplify overload, and asynchronous queues introduce delivery and ordering concerns. Microservices also increase the need for deployment automation, access control, secrets management and consistent platform tooling. The right question is not whether a system can be divided into services, but whether independent deployment and ownership create enough value to justify the operational complexity. A well-structured monolith can be a better starting point for many products.

See also

  • Idempotency – The property of an operation that produces the same result whether it is applied once or many times.
  • Kubernetes – An open-source system for automating deployment, scaling and management of containerised applications.
  • CAP Theorem – A result stating that a distributed data store cannot simultaneously guarantee consistency, availability and partition tolerance.
  • Docker – A platform for building, distributing and running applications in containers.
  • PostgreSQL – An open-source object-relational database system with a strong emphasis on standards compliance and extensibility.
  • Big-O Notation – A notation describing how the resource use of an algorithm grows as the input size grows.
  • Domain Name System (DNS) – The distributed naming system that translates human-readable domain names into records used to locate internet services.
  • Event Loop – A programming construct that waits for and dispatches events or messages in a single thread of control.

References

  1. ↑ Martin Fowler: Microservices (martinfowler.com)
  2. ↑ Microsoft Architecture Center: Microservices architecture (learn.microsoft.com)
  3. ↑ Google Cloud Architecture Framework (cloud.google.com)