Bird
Raised Fist0
HLDsystem_design~20 mins

Saga pattern for distributed transactions in HLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Saga Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the primary purpose of the Saga pattern in distributed systems?

Choose the best explanation for why the Saga pattern is used in distributed transactions.

ATo replicate data synchronously between microservices for consistency.
BTo batch multiple requests into one to reduce network calls.
CTo coordinate a sequence of local transactions across services with compensating actions on failure.
DTo ensure all distributed services commit or rollback changes atomically like a single database transaction.
Attempts:
2 left
💡 Hint

Think about how distributed systems handle failures without locking resources.

Architecture
intermediate
2:00remaining
Which component is essential in a Saga orchestration-based architecture?

Identify the key component responsible for managing the sequence of transactions and compensations in an orchestration-based Saga.

AA load balancer that routes requests to different microservices.
BA distributed event bus that broadcasts events without central control.
CA shared database that all services use to coordinate commits.
DA centralized Saga orchestrator that commands each service to execute or compensate transactions.
Attempts:
2 left
💡 Hint

Consider which part controls the flow of the Saga steps explicitly.

scaling
advanced
2:00remaining
How does the Saga pattern help improve scalability compared to distributed two-phase commit (2PC)?

Choose the best explanation of how Saga supports scalability in distributed systems.

ASaga avoids locking resources across services, allowing independent progress and reducing bottlenecks.
BSaga uses synchronous blocking calls to ensure all services commit simultaneously.
CSaga requires a global lock on all services to maintain consistency.
DSaga replicates all data to a central node to speed up transactions.
Attempts:
2 left
💡 Hint

Think about how locking affects system throughput and concurrency.

tradeoff
advanced
2:00remaining
What is a key tradeoff when using the Saga pattern for distributed transactions?

Identify the main downside of using Saga compared to traditional atomic transactions.

AData consistency is eventually consistent, not strongly consistent during the transaction.
BIt requires all services to share the same database schema.
CIt guarantees immediate rollback of all changes on failure.
DIt eliminates the need for compensating transactions.
Attempts:
2 left
💡 Hint

Consider how Saga handles failures and data visibility during the process.

estimation
expert
2:00remaining
Estimate the number of compensating transactions needed if a Saga with 5 steps fails at step 4.

A Saga consists of 5 sequential local transactions. If the transaction fails at step 4, how many compensating transactions must be executed to rollback?

A4 compensating transactions
B3 compensating transactions
C5 compensating transactions
D1 compensating transaction
Attempts:
2 left
💡 Hint

Think about which steps have already committed before failure and need compensation.