Filtered Replication vs View-Based Extraction: Which Minimizes CPU Load During Large Syncs?
0 reputation · 02 Jun 2020, 02:18 UTC
0 reputation · 02 Jun 2020, 02:18 UTC
When synchronizing large CouchDB datasets, the choice between filtered replication and view-based extraction can significantly affect resource consumption. The goal is to keep CPU usage on the source node within acceptable limits while still delivering only the desired subset of documents to the target.
Filtered replication evaluates a JavaScript filter for every document considered for replication, which can become expensive as the database grows. View-based extraction, on the other hand, relies on pre-built design documents and indexes, potentially reducing per-document overhead but requiring an additional query step before initiating the replication.
Uncertainty remains about which approach yields lower overall CPU load and faster completion times for typical large-scale syncs. Additionally, it is unclear how replication latency scales when the filter logic is complex versus when the view index is highly selective.
How does the per-document sandbox execution in filtered replication impact CPU usage compared to the pre-filtering cost of view-based extraction? What are the trade-offs in replication latency and resource consumption between the two methods? Can view-based extraction fully replace filtered replication for selective data movement without increasing round‑trip overhead?
34775 reputation · 02 Jun 2020, 09:28 UTC
For large, relatively static datasets with stable selection criteria, view-based extraction minimizes source-node CPU during synchronization because filtering work is shifted to incremental view index maintenance (amortized over writes) rather than per-document JavaScript execution during each replication run. Filtered replication remains preferable for ad-hoc or frequently changing filters, small datasets, or when avoiding additional design documents is a priority.
_bulk_get or ID-range fetch without per-document JS evaluation.| Aspect | Filtered Replication | View-Based Extraction |
|---|---|---|
| Per-sync CPU (source) | High – JS filter per document | Low – index already built |
| Write amplification | None | Index maintenance on every write/update |
| Initial index cost | N/A | One-time spike comparable to a full filtered pass |
| Replication latency | Single round-trip | Extra round-trip: view query → ID list → replication |
| Filter flexibility | Ad-hoc, dynamic logic | Stable criteria; changing filter requires index rebuild |
| Disk overhead | None | 10–30% of data size per view index |
/_node/_local/_stats and monitor cpu, replication, and view_indexer metrics./_active_tasks during initial creation.What is the typical rate of document writes/updates relative to sync frequency? If writes are very frequent, view index maintenance cost may shift the CPU burden back to the source node during write peaks, altering the recommendation.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.