Database / Azure Cosmos DB interview questions
How does global distribution work in Azure Cosmos DB?
Cosmos DB is built from the ground up for global distribution. Every account has a single write region by default (or multiple write regions with multi-master enabled), and you can add any number of read regions at any time. Cosmos DB automatically replicates all data to every configured region using a proprietary replication protocol that targets the configured consistency level.
Adding a region is a portal/CLI toggle, not a manual data migration. Cosmos DB handles all the replication behind the scenes. The 99th-percentile read and write latency is under 10 ms within a region, and under 10 ms for reads from any region (since reads go to the nearest read replica). Writes in single-write-region mode are synchronous to the primary region and asynchronous to read regions.
The replication model depends on consistency level. With Strong consistency, every write must be acknowledged across a quorum of replicas in all regions before returning — this means write latency scales with inter-region round-trip time. With Eventual or Session consistency, writes return after the local quorum acknowledges, and other regions catch up asynchronously.
Automatic failover can be configured so that if the primary write region goes down, Cosmos DB automatically promotes the next region in your priority list to become the new write region. You can test this with manual failover in the portal without data loss (because replicas are always in sync up to the consistency level you chose).
Conflict resolution applies when multi-region writes are enabled and two clients in different regions write to the same item concurrently. Cosmos DB resolves this with Last-Write-Wins (based on a server-side timestamp or custom _ts) or a custom conflict resolution procedure you define.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
