All Questions
Sharding hard

When building a sharded banking system, a transfer requires debiting User A on Shard 1 and crediting User B on Shard 2. If 'Two-Phase Commit' is rejected due to performance, how does the 'Saga' pattern resolve this?

  1. A It locks both shards simultaneously using an external hardware distributed lock manager.
  2. B It executes each operation as a local transaction and, if a later step fails, it executes 'Compensating Transactions' (e.g., a refund) to manually restore consistency.
  3. C It converts the database into a single-master architecture temporarily to process the transaction.
  4. D It uses a blockchain ledger to ensure that all shards eventually agree on the final balance.

One system design question a day, with spaced repetition so the ones you miss come back.

Get the app

Related questions