Microservices Interservice Communication Strategies 3 — Questions and Answers
Question 1: What problem does the Saga pattern primarily solve in microservices?
- Managing distributed transactions without a global lock (Correct answer)
- Caching service responses
- Load balancing requests
- Compressing message payloads
Correct answer: Managing distributed transactions without a global lock
Sagas coordinate a sequence of local transactions with compensating actions instead of a distributed lock.
Question 2: In a choreography-based saga, how do services coordinate?
- By reacting to events each other publishes (Correct answer)
- Through a central orchestrator issuing commands
- Via a shared database lock
- Through synchronous RPC chains only
Correct answer: By reacting to events each other publishes
Choreography relies on each service emitting and reacting to events without a central coordinator.
Question 3: What is a compensating transaction in a saga?
- An action that semantically undoes a prior committed step (Correct answer)
- A retry of the same operation
- A read-only validation query
- A two-phase commit prepare phase
Correct answer: An action that semantically undoes a prior committed step
Since steps already committed, a compensating transaction reverses their effect logically.
Question 4: Which messaging delivery guarantee may deliver the same message more than once?
- At-least-once (Correct answer)
- Exactly-once
- At-most-once
- Zero-once
Correct answer: At-least-once
At-least-once retries until acknowledged, which can cause duplicates.
Question 5: What technique makes a consumer safe against duplicate message delivery?
- Idempotent processing (Correct answer)
- Disabling acknowledgments
- Increasing the timeout
- Using larger batch sizes
Correct answer: Idempotent processing
Idempotent handlers produce the same result no matter how many times a message is processed.
Question 6: An orchestration-based saga differs from choreography because it uses a:
- Central coordinator that directs each step (Correct answer)
- Shared in-memory cache
- Broadcast-only event bus
- Single monolithic database
Correct answer: Central coordinator that directs each step
Orchestration centralizes saga logic in a coordinator that tells participants what to do.
Question 7: Which is a trade-off of choreography compared to orchestration?
- The overall workflow is harder to visualize and debug (Correct answer)
- It requires a single point of failure
- It cannot use asynchronous messaging
- It forces synchronous calls
Correct answer: The overall workflow is harder to visualize and debug
With no central place defining the flow, understanding the end-to-end process becomes harder.
What problem does the Saga pattern primarily solve in microservices?