Skip to content
IRC-Coding IRC-Coding
Microservices Bounded Context Saga Resilience Observability Event-Driven API Gateway

Microservices Architecture: Bounded Context, Saga & Resilience

Master microservices architecture: independent deployable services, Sagas for distributed transactions, resilience patterns, and observability.

S

schutzgeist

2 min read

Microservices Architecture

This article is a glossary entry on microservices – including exam questions and tags.

In a Nutshell

Microservices are small, independently deployable services with clearly defined business responsibility. Each service encapsulates its data and communicates via well-defined interfaces.

Compact Technical Description

In microservices architecture, a system is divided into business-aligned services, often along a Bounded Context from DDD. Each service owns its own data model and its own persistence store. Communication is preferably asynchronous via events; for synchronous needs, lightweight APIs like REST or gRPC are used. Deployments are independent; Continuous Delivery enables fast increments. Consistency is usually eventual; distributed transactions are coordinated via Sagas. Observability is mandatory: structured logs, metrics, traces, and correlation IDs are necessary to track distributed calls.

Exam-Relevant Key Points

  • Cutting along business domain, one Bounded Context per service, data per service, no shared schema
  • Communication styles: asynchronous messaging for decoupling, synchronous used sparingly
  • Data consistency: Sagas, Outbox, Inbox, idempotent processing, exactly-once semantics
  • Name quality goals: changeability, availability, security, traceability (SLOs)
  • Independent repos, build, test, deploy per service, Consumer Driven Contract Tests
  • Security aspect: mTLS, OAuth 2/OIDC, Secrets Management, Policy Enforcement, Rate Limiting
  • Economics: team autonomy, parallel development, scaling per hotspot, higher operational overhead
  • Documentation requirement: C4 Model Level 1-3, interface contracts, ADRs, operations guide, disaster plan

Core Components

  1. Business cutting, Bounded Context per service
  2. API Design: resources or RPC, versioning, backward compatibility
  3. Data per service: independent persistence, migration strategy
  4. Communication layer: Message Broker, Queue, Stream, Request-Response
  5. Service Discovery and Routing: API Gateway, Ingress
  6. Resilience: Circuit Breaker, Timeouts, Retries with Backoff, Bulkheads
  7. Observability: Logs, Metrics, Tracing, Correlation ID
  8. Deployment and Infrastructure: Container, Orchestration, IaC, CI/CD
  9. Security: mTLS, AuthN/AuthZ, Secrets Management, Audit Logging
  10. Testing approaches: Unit, Integration, Contract Tests, Chaos Engineering, Load Testing

Practical Example

// Saga, Orchestrated: Order process with Order Service, Payment Service, Inventory Service
POST order/create { customerId: 42, items: [{ sku: "A1", qty: 2 }] }

Order Service stores Order status: pending, generates Event: order.created (outbox)
Orchestrator receives order.created, calls Payment Service:
POST payments with Idempotency Key: ord-42

Payment Service authorizes amount, publishes Event: payment.authorized
Orchestrator calls Inventory Service:
POST reservations { orderId: 42, items: ... }

Inventory reserves items, publishes Event: inventory.reserved
Orchestrator sets Order to status: confirmed, publishes order.confirmed

Compensation on inventory.reservation.failed:
- Calls Payment Service: POST payments/refund
- Sets Order to cancelled

Advantages and Disadvantages

Advantages

  • Independent deployments, faster changes
  • Targeted scaling, better fault isolation
  • Technology diversity per service, clear responsibilities
  • Team autonomy, parallel development

Disadvantages

  • Higher operational complexity
  • Distributed debugging, network failures and latencies
  • Data consistency must be explicitly modeled
  • Demanding observability and security
  • Risk of a Distributed Monolith

Typical Exam Questions (with Short Answers)

  1. Business cutting for microservices? Along a Bounded Context with clear Ubiquitous Language, minimal coupling, maximum cohesion.
  2. Distributed transactions without Two Phase Commit? Via Saga with orchestration/choreography, idempotent compensation steps, Outbox Pattern.
  3. Problem with synchronous call chains? Amplify latencies/failures, cascade effects, reduce autonomy. Countermeasures: asynchronous events, Circuit Breaker.
  4. Data per service in practice? Each service owns its own persistence schema, hides it behind API, integrations via events/APIs.
  5. Role of API Gateway? Central entry point: routing, authentication, rate limits, observability, protocol translation.
  6. Traceability across service boundaries? Correlation IDs, distributed tracing, structured logs, consistent propagation across all calls.
  7. When economically justified? With larger teams and complex domains, when independent deployments justify operational overhead.
  8. Consistency vs. availability in CAP? Usually higher availability with eventual consistency, local invariants strictly enforced, global via Sagas.

Most Important Sources

  1. https://microservices.io
  2. https://martinfowler.com/microservices
  3. https://learn.microsoft.com/azure/architecture/guide/architecture-styles#microservices
Back to Blog
Share:

Related Posts