I know MongoDB supports multi-document transactions now, but I hear they have a performance cost. Is it better to restructure my schema to avoid transactions entirely, or should I lean into them for financial data? I want to ensure my design is robust but also scalable. What are the best practices here?
Designing schemas to utilize atomic single-document operations minimizes latency and avoids the significant performance overhead associated with multi-document transactions in sharded environments.
2 answers
Restructure your schema to avoid transactions whenever possible, because performance penalties on sharded clusters are non-negotiable once you hit high concurrency. Transactions are a safety net for edge cases, not a replacement for proper document modeling.
I remember sitting in a war room three years ago while our main legacy dashboard crawled to a halt because some developer thought ACID compliance on a non-critical micro-service was a good idea. We spent two weeks unraveling locking contention that brought our entire write throughput to its knees.
You think you need the safety, but you usually just need to think about your document boundaries differently. If your financial data requires frequent multi-document updates, your aggregate root is likely defined incorrectly, or you are forcing a relational mental model onto a document store.

