Skip to main content

How do you design a multi-shard transaction strategy to avoid large distributed rollbacks?

Expert MongoDB
Quick Answer To avoid large distributed transactions: design schemas so related data lives on the same shard (same shard key prefix), use event sourcing or saga patterns for multi-shard workflows instead of transactions, break large operations into smaller single-shard transactions with compensating logic, and use the transactional outbox pattern to coordinate across service boundaries without cross-shard transactions.

Answer

Keep transactions small, align operations with shard keys, avoid multi-collection writes, and reduce batch size to prevent distributed rollback overhead.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice