Database / CouchDB Interview Questions
What are the CAP theorem trade-offs for CouchDB — is it CP or AP?
CouchDB is an AP system — it prioritizes Availability and Partition tolerance over strict Consistency. When a network partition occurs, CouchDB nodes on either side continue accepting reads and writes rather than refusing requests to maintain linearizability. The result is that two nodes can hold diverged versions of the same document (called open conflicts) until replication heals the partition.
CouchDB's consistency model is eventual consistency: after a partition heals and replication runs, all nodes converge. The conflict resolution mechanism — the deterministic winning-revision algorithm plus application-level merge — is how convergence is achieved without a global coordinator.
The AP versus CP distinction surfaces in these specific scenarios:
- Multi-master replication — both nodes independently accept writes to the same document. The replication protocol syncs them and surfaces the conflict for application resolution.
- CouchDB 3.x cluster quorum settings — the write quorum
wand read quorumrdefault to a majority ofnreplicas. Raising both tonmakes the cluster refuse writes when a node is down, shifting behavior toward CP at the cost of availability.
This AP design is the reason CouchDB excels in offline-first and mobile applications via PouchDB: the mobile client writes locally (always available) and syncs to the server when connectivity returns, with conflicts resolved deterministically.
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...
