Medium1 markMultiple Choice
Domain 4.2: Application ArchitectureDomain 4MicroservicesDesign PatternsSaga

AZ-305 · Question 44 · Domain 4.2: Application Architecture

You are designing a distributed microservices application.

A business transaction spans three microservices: Order, Payment, and Inventory. Each microservice has its own dedicated database. If the Order and Payment steps succeed, but the Inventory step fails (e.g., item out of stock), the system must undo the Order and Payment steps to maintain data consistency.

Which architectural pattern should you implement?

Answer options:

A.

Two-Phase Commit (2PC)

B.

Saga pattern

C.

Command and Query Responsibility Segregation (CQRS)

D.

Circuit Breaker pattern

How to approach this question

Identify the standard microservices pattern used for managing distributed transactions and rollbacks.

Full Answer

B.Saga pattern✓ Correct
Saga pattern
In a microservices architecture where each service has its own database, traditional ACID transactions (like Two-Phase Commit) are difficult to implement and scale poorly. The Saga pattern is the recommended approach. A saga is a sequence of local transactions. Each local transaction updates the database and publishes a message to trigger the next step. If a step fails, the saga executes 'compensating transactions' to undo the changes made by the preceding steps.

Common mistakes

Choosing Two-Phase Commit. While 2PC does distributed transactions, it is an anti-pattern in cloud-native microservices due to blocking and tight coupling.

Practice the full Azure Solutions Architect Expert AZ-305 Practice Exam 2

55 questions · hints · full answers · grading

More questions from this exam