Database / CouchDB Interview Questions
What is the difference between one-shot and continuous replication in CouchDB?
CouchDB supports two replication modes: one-shot (the default) and continuous. The mode is set by the continuous boolean in the replication document.
One-shot replication syncs all documents changed since the last checkpoint, then completes. The replication job disappears once finished. It is appropriate for scheduled batch syncs, point-in-time backups, or bootstrapping a new replica.
Continuous replication runs indefinitely after initial sync. It keeps a long-lived _changes feed connection open to the source, processing new changes as they arrive in near real-time. The replication job persists in the _replicator database and is restarted automatically after node restarts.
# One-shot replication via _replicator database
curl -X POST http://admin:pass@localhost:5984/_replicator \
-H "Content-Type: application/json" \
-d '{
"_id": "one-time-backup",
"source": "http://localhost:5984/mydb",
"target": "http://replica:5984/mydb",
"continuous": false,
"create_target": true
}'
# Continuous replication
curl -X POST http://admin:pass@localhost:5984/_replicator \
-H "Content-Type: application/json" \
-d '{
"_id": "live-sync-to-replica",
"source": "http://localhost:5984/orders",
"target": "http://replica:5984/orders",
"continuous": true
}'
# Check replication status
curl http://admin:pass@localhost:5984/_scheduler/jobs
Continuous replication introduces a persistent connection that consumes resources on both nodes. For high-volume databases, monitor the scheduler via /_scheduler/jobs and /_scheduler/docs to detect stalled or crashing replication jobs. A job that enters a crash-loop loop usually indicates a network issue, authentication problem, or an unfixable conflict on the target.
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...
