Production Deployment & Mesh Replication
Deploy to production with proper config, enable mesh replication for HA, and apply the full checklist.
What you'll learn
- ✓Production docker-compose.yml: restart: always, named volumes, healthcheck
- ✓Secrets management: Railway shared vars, AWS Secrets Manager, Kubernetes sealed secrets
- ✓POST /v1/mesh/peers — register a replica node
- ✓Both nodes share SAPIX_MASTER_SEED — same encryption, same data
- ✓Full production checklist: 13 items from secrets backup to Codios auth
- ✓Performance tuning: high_load profile, batch writes, index strategy
Deploy a two-node setup with mesh replication. Write to node 1. Verify on node 2. Run chain verification on both.
Interactive Walkthrough
What you'll learn
Deploy SapixDB to production with proper configuration, enable mesh replication for high availability, and apply the full production checklist.
Production docker-compose.yml
services:
sapixdb:
image: sapixdb/agent:latest
container_name: sapixdb
restart: always
ports:
- "7475:7475"
volumes:
- /var/lib/sapixdb/strand:/data/strand
- /var/lib/sapixdb/graph:/data/graph
- /var/lib/sapixdb/blobs:/data/blobs
environment:
SAPIX_AGENT_ID: production-primary
SAPIX_MASTER_SEED: ${SAPIX_MASTER_SEED}
SAPIX_KEYPAIR_SEED_HEX: ${SAPIX_KEYPAIR_SEED_HEX}
SAPIX_ROOT_KEY: ${SAPIX_ROOT_KEY}
SAPIX_LICENSE_KEY: ${SAPIX_LICENSE_KEY}
SAPIX_STRAND_DIR: /data/strand
SAPIX_GRAPH_DIR: /data/graph
SAPIX_BLOB_DIR: /data/blobs
SAPIX_BIND_ADDR: 0.0.0.0:7475
SAPIX_CODIOS_URL: ${SAPIX_CODIOS_URL}
SAPIX_CODIOS_API_KEY: ${SAPIX_CODIOS_API_KEY}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7475/v1/health"]
interval: 30s
timeout: 10s
retries: 3Production secrets management
Never put secrets in docker-compose.yml directly. Use:
- Railway: shared environment variables
- AWS: Secrets Manager + ECS task role
- Kubernetes: sealed secrets or external secrets operator
- Docker Swarm: docker secret
# Pass from environment
SAPIX_MASTER_SEED=<hex> SAPIX_ROOT_KEY=<key> docker compose up -dMesh replication (high availability)
Register a peer node:
curl -s -X POST http://localhost:7475/v1/mesh/peers \
-H "Content-Type: application/json" \
-H "Authorization: Bearer spx_root_YOUR_ROOT_KEY" \
-d '{
"peer_id": "replica-01",
"endpoint": "http://replica-host:7475",
"api_key": "spx_root_REPLICA_ROOT_KEY"
}' | python3 -m json.toolSapixDB pushes all writes to registered peers. Both nodes share the same SAPIX_MASTER_SEED (same encryption key, same data). Reads can go to either node.
Production checklist
| Item | Required? |
|---|---|
SAPIX_MASTER_SEED set and backed up offline | Critical |
SAPIX_ROOT_KEY in secrets manager | Critical |
SAPIX_KEYPAIR_SEED_HEX backed up | Critical |
restart: always in docker-compose | Required |
Volume mount to named directory (not /tmp) | Required |
| Chain verification in health check | Recommended |
| Daily snapshot via cron | Recommended |
| Scoped API keys for all services (no root key in app code) | Required |
SAPIX_LICENSE_KEY set for enterprise features | If using enterprise |
| Peer replica configured | Recommended for HA |
SAPIX_CODIOS_URL set for agent authorization | Recommended |
| HIPAA/SOX mode if applicable | Compliance |
Performance tuning
| Scenario | Setting |
|---|---|
| High write throughput | Switch to high_load profile |
| Large analytics queries | Switch to analytics profile |
| Mixed OLTP | default profile |
| Maintenance window | maintenance profile |
Use batch writes for all bulk ingestion (Lesson 8). Create indexes on frequently filtered fields (Lessons 18–20). Use count and aggregate instead of loading full records for stats.
Final challenge
Deploy a two-node SapixDB setup with mesh replication. Write a record to node 1. Verify it appears on node 2. Run chain verification on both nodes.
---
## Summary — All 50 Lessons
| # | Lesson | Module |
|---|---|---|
| 1 | The Mental Model | Foundations |
| 2 | First Boot | Foundations |
| 3 | Record Anatomy | Foundations |
| 4 | Organisms and Agents | Foundations |
| 5 | Writing Records in Depth | Foundations |
| 6 | Reading Records in Depth | Foundations |
| 7 | Soft Delete and Tombstones | Working with Records |
| 8 | Batch Writes | Working with Records |
| 9 | Per-Record TTL | Working with Records |
| 10 | Schema Validation | Working with Records |
| 11 | SaQL Basics | Querying with SaQL |
| 12 | All 15 WhereOp Operators | Querying with SaQL |
| 13 | Compound Filters (AND/OR/NOT) | Querying with SaQL |
| 14 | Sort Order & Cursor Pagination | Querying with SaQL |
| 15 | Aggregate Functions | Querying with SaQL |
| 16 | Group By | Querying with SaQL |
| 17 | Distinct Queries | Querying with SaQL |
| 18 | Single-Field Indexes | Indexes & Performance |
| 19 | Composite Indexes | Indexes & Performance |
| 20 | Full-Text Search | Indexes & Performance |
| 21 | Query Explain | Indexes & Performance |
| 22 | Time Travel Deep Dive | Time & History |
| 23 | Time Range Queries | Time & History |
| 24 | Chain Verification | Time & History |
| 25 | Graph Edges | Graph & Joins |
| 26 | Graph Traversal | Graph & Joins |
| 27 | Multi-Agent Joins | Graph & Joins |
| 28 | Field Projection | Advanced Query |
| 29 | Natural Language Queries | Advanced Query |
| 30 | Streaming Queries (SSE) | Advanced Query |
| 31 | BlobStore | Binary Storage |
| 32 | SAPIX_MASTER_SEED & Encryption | Auth & Security |
| 33 | Root Key & API Authentication | Auth & Security |
| 34 | Scoped API Keys | Auth & Security |
| 35 | Key Delegation & Rate Limiting | Auth & Security |
| 36 | Key Rotation | Auth & Security |
| 37 | Cron Jobs | Automation |
| 38 | Triggers | Automation |
| 39 | Mutants (AI Schema Evolution) | Automation |
| 40 | Per-Agent SSE Stream | Real-Time |
| 41 | Global Broadcast Bus & Publications | Real-Time |
| 42 | Epigenetic Profiles | Operations |
| 43 | Snapshots & Backups | Operations |
| 44 | WAL & Checkpoints | Operations |
| 45 | HIPAA Compliance Mode | Enterprise |
| 46 | SOX Compliance | Enterprise |
| 47 | Codios Authorization | Enterprise |
| 48 | Python SDK | SDKs |
| 49 | TypeScript SDK | SDKs |
| 50 | Production Deployment & Mesh Replication | Production |
---
*Lessons 1–6 complete. Proceed from Lesson 7 onward one at a time.*