Microservices Microservice Design Patterns 2 — Questions and Answers
Question 1: Which pattern decomposes a monolith by grouping services around distinct business capabilities?
- Decompose by business capability (Correct answer)
- Strangler Fig
- Sidecar
- Bulkhead
Correct answer: Decompose by business capability
Decompose by business capability aligns each service with a function the business performs.
Question 2: What is the primary purpose of the Saga pattern?
- Manage data consistency across services without distributed transactions (Correct answer)
- Cache responses at the gateway
- Balance load between instances
- Encrypt inter-service traffic
Correct answer: Manage data consistency across services without distributed transactions
Saga coordinates a sequence of local transactions with compensating actions to maintain consistency.
Question 3: In a choreography-based saga, how do services coordinate?
- By exchanging events without a central controller (Correct answer)
- Through a central orchestrator service
- Via synchronous REST chains
- Using a shared database lock
Correct answer: By exchanging events without a central controller
Choreography relies on each service reacting to events published by others.
Question 4: Which pattern provides a single entry point that routes client requests to backend services?
- API Gateway (Correct answer)
- Event Sourcing
- CQRS
- Circuit Breaker
Correct answer: API Gateway
An API Gateway aggregates and routes requests, handling cross-cutting concerns.
Question 5: What problem does the Circuit Breaker pattern primarily solve?
- Preventing cascading failures from a failing dependency (Correct answer)
- Storing event history
- Splitting reads and writes
- Discovering service instances
Correct answer: Preventing cascading failures from a failing dependency
A circuit breaker stops calls to a failing service to avoid resource exhaustion and cascading failure.
Question 6: The Database-per-Service pattern primarily promotes what?
- Loose coupling and independent data ownership (Correct answer)
- Shared schema reuse
- Cross-service joins
- Centralized transaction control
Correct answer: Loose coupling and independent data ownership
Each service owning its database prevents tight coupling through a shared schema.
Question 7: Which pattern lets you incrementally migrate a monolith by intercepting and replacing functionality over time?
- Strangler Fig (Correct answer)
- Bulkhead
- Sidecar
- Ambassador
Correct answer: Strangler Fig
The Strangler Fig pattern gradually replaces legacy features behind a routing facade.
Which pattern decomposes a monolith by grouping services around distinct business capabilities?