Production Operations
Health probes, Prometheus metrics, system diagnostics, graceful drain, dumps/exports, and hardening checklist.
Deploy, monitor, tune, export, and upgrade SpydDB clusters predictably in production environments.
1. Probes, Prometheus Metrics & Readiness (metrics_bind)#
Configure metrics_bind on loopback (or a private operational interface) to expose /healthz, /readyz, and Prometheus /metrics:
curl -fsS http://127.0.0.1:9090/healthz # 200 while process is alive
curl -fsS http://127.0.0.1:9090/readyz # 503 immediately when server begins draining
curl -fsS http://127.0.0.1:9090/metrics # Prometheus text expositionOn the public HTTP listener (http_bind), GET /v1/health reports liveness, draining status, storage state, and server version without requiring credentials (200 healthy, 503 draining/storage error):
{"status":"ok","draining":false,"storage":"ok","version":"1.0.0"}Key Prometheus Counters & Histograms#
| Metric | Type | Signal |
|---|---|---|
spyd_connections_total / spyd_active_connections | counter / gauge | Accepted & active client connections |
spyd_authentication_failures_total | counter | Rejected credentials / potential credential stuffing |
spyd_frames_rejected_total | counter | Malformed, oversized, or bad CRC32C SpydWire frames |
spyd_queries_total / spyd_queries_failed_total / spyd_queries_cancelled_total | counter | Execution volume, query errors, and cancellations |
spyd_http_requests_total / spyd_http_requests_failed_total | counter | HTTP API throughput & 4xx/5xx rate |
spyd_query_latency_seconds | histogram | Engine query duration buckets (1ms .. 5s) |
2. Live Engine Diagnostics & Online Maintenance#
Query internal operational health directly via SpydQL:
system | stats buffer_pool
system | stats wal
system | stats storage
system | stats catalog
system | stats security
system | stats indexes
system | stats partitions
system | stats access
system | stats all
system | stats collection orders
system | queries activeOnline MVCC Maintenance (maintain & maintain purge)#
SpydDB reclaims obsolete row versions, expired tombstones, obsolete columnar segments, and unreferenced chunked blobs online without stopping reads or concurrent writers:
-- Retention-respecting reclamation (preserves history inside version_retention_secs)
maintain
-- Aggressive purge up to the oldest active reader snapshot or prepared 2PC transaction
maintain purge- Non-blocking execution: Collection runs cooperatively with read-locked access, clamps the garbage-collection horizon to both
version_retention_secs(formaintain) and the oldest active transaction snapshot / prepared 2PC horizon, and uses a write sweep barrier so concurrent large-blob commits never race with reclamation. - Internal free-list reuse: Freed storage pages are flushed back to SpydDB's internal free list for immediate reuse; running maintenance does not shrink database files on disk.
- Cooperative cancellation & least privilege: Long maintenance runs honor
POST /v1/cancel/{query_id}and require onlymanage on database(maintenance)rather than full security administration.
Profile slow queries with actual row counts & timing per operator:
explain analyze orders | where status == "paid" | sort placed_at desc | take 1003. Graceful Shutdown & Zero-Drop Upgrades#
Sending SIGINT or SIGTERM initiates a deterministic drain sequence:
/readyzand/v1/healthimmediately return503so load balancers stop routing new traffic.- Open keep-alive idle connections close; in-flight queries finish cleanly within the graceful drain timeout.
- Uncommitted interactive transactions roll back cleanly, and remaining WAL buffers flush to disk.
Upgrading Safely#
- Verify config compatibility before restarting:sh
spyd-server --config /etc/spyd/server.json --check - Take an online verified backup via
POST /v1/admin/backups+POST /v1/admin/backups/verify. - Drain and restart the node cleanly (
SIGTERM) or swap rolling cluster standbys.
4. Database Administration, Logical Dumps & Streaming Exports#
Multi-Database Management (HTTP Admin API & pgwire)#
# List served databases
curl -sS --cacert tls/ca.crt https://localhost:8080/v1/admin/databases \
-H "Authorization: Bearer $SPYD_ADMIN_TOKEN"
# Create a new database (inherits caller database role layout)
curl -sS -X POST --cacert tls/ca.crt https://localhost:8080/v1/admin/databases \
-H "Authorization: Bearer $SPYD_ADMIN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "analytics"}'Whole-Database Dumps (spyd-cli)#
# Full-fidelity SpydDB native JSON dump & restore
spyd-cli --embedded --data /var/lib/spyd --dump /var/backups/db.spyd.json
spyd-cli --embedded --data /var/lib/spyd-restored --restore /var/backups/db.spyd.json
# Portable PostgreSQL SQL dump & restore
spyd-cli --embedded --data /var/lib/spyd --dump-sql /var/backups/db.sql
spyd-cli --embedded --data /var/lib/spyd-restored --restore-sql /var/backups/db.sqlStreaming Query Exports (CSV / NDJSON / GZIP)#
Stream arbitrarily large query results directly to disk without hitting frame size limits:
spyd-cli --embedded --data /var/lib/spyd \
--query 'orders | pick id, customer, total, placed_at' \
--export /var/backups/orders.ndjson.gz \
--export-columns /var/backups/orders.columns.json5. Production Hardening Checklist#
- Keep
"environment": "production"set so non-TLS listeners refuse startup. - Enable
--cap-drop ALL --cap-add IPC_LOCKand unlimitedmemlock("lock_memory": true) in Docker/systemd. - Store tokens (
env:...), TLS keys,storage.encryption_key_path, and column keyrings outsidedata_dirwith mode0600. - Restrict public network access via
"network": { "allowed_cidrs": [...] }. - Configure
backup_rootand ship sealed audit segments & backups off-host to immutable object storage.