Database / CouchDB Interview Questions
How do you monitor CouchDB performance using the _stats and _active_tasks endpoints?
CouchDB exposes two key monitoring endpoints out of the box — /_stats and /_active_tasks — which together give a real-time snapshot of server health and ongoing operations.
GET /_stats returns a JSON object of cumulative performance counters organized by category. Key metrics to watch:
httpd.requests.value— total HTTP requests processed.httpd_request_methods.{GET,PUT,POST,DELETE}.value— breakdown by HTTP verb.httpd_status_codes.{200,201,400,404,409,500}.value— response code breakdown; rising 409s may indicate conflict storms; rising 500s indicate bugs.couchdb.open_databases.value— number of databases currently open (compare tomax_dbs_open).couchdb.request_time.value— mean, min, max request latency.
curl http://admin:pass@localhost:5984/_stats | python3 -m json.tool | head -60
# On a cluster, query per node:
curl http://admin:pass@localhost:5984/_node/couchdb@node1/_stats
GET /_active_tasks returns a live array of currently running background tasks. Each task has a type field:
database_compaction— compaction progress as a percentage.view_compaction— view index compaction progress.indexer— a view index being built or incrementally updated.replication— active replication job with checkpoint seq and docs per second.
curl http://admin:pass@localhost:5984/_active_tasks
# [{"type":"indexer","node":"couchdb@node1","design_document":"_design/orders",
# "view":"by_status","started_on":1700000000,"updated_on":1700000010,
# "progress":45}]
For production monitoring, both endpoints integrate with Prometheus via the community couchdb-exporter, allowing dashboards in Grafana alongside alerting on queue depth, error rates, and compaction lag.
More Related questions...