Storage & Cluster
Storage paths, WAL, HNSW shape, scheduler intervals, blob backends, cold backups, and clusters.
CortexDB stores everything on one canonical write path: an append-only WAL backed by RocksDB. Every searchable index (HNSW vectors, Tantivy fulltext, the KG, materialized views) is a derivative of that WAL. Restore the WAL and you can rebuild every index.
Storage paths and durability
[storage]
data_path = "/data/cortex" # default
wal_sync = true # default
max_disk_usage_percent = 95 # default| Field | Type | Default | What it controls |
|---|---|---|---|
data_path | PathBuf | /data/cortex | Root for RocksDB, Tantivy, and the WAL. |
wal_sync | bool | true | fsync() after every WAL append. false = ~10 ms durability gap, ~2 to 5× faster writes. |
max_disk_usage_percent | u8 [0..100] | 95 | Soft refuse-writes watermark. At this fullness /v1/experience returns 507. |
The default /data/cortex suits the Docker/k8s shape (mount a real volume there); bare-metal usually
overrides to /var/lib/cortexdb. The config file is read from <data_dir>/cortex.toml (the CLI data dir, /data on the image),
independent of data_path. wal_sync = false (or CORTEX_WAL_SYNC=0) is the explicit
faster/weaker opt-out: fine for voice/realtime, not for financial/medical/compliance workloads.
max_disk_usage_percent is a soft floor (RocksDB itself doesn't refuse writes): keep ~10% headroom on
the actual disk.
The extraction cache
Alongside the stores, the data directory holds an extraction cache that lets repeated extraction
work skip the model call. It is retired and always off: the boot lint reports
CORTEX_EXTRACTION_CACHE = always OFF (retired; no value re-enables automatic caching). What remains
is measuring and purging a cache left behind by an older version (at <data_dir>/extraction_cache):
| Env var | Default | What it controls |
|---|---|---|
CORTEX_EXTRACTION_CACHE | always off (retired) | No value re-enables caching; call sites send no cache key. |
CORTEX_EXTRACTION_CACHE_PURGE | (unset = off) | A boot measures the retired cache and deletes nothing; only =1 destroys it before bind (it holds paid LLM extraction responses). |
CORTEX_EXTRACTION_CACHE_DIR | <data_dir>/extraction_cache | An extra location to measure/purge; never a place caching resumes. |
CORTEX_EXTRACTION_CACHE_RAM_CAP | 4096 entries | In-memory tier size; 0 disables the RAM tier. |
CORTEX_EXTRACTION_CACHE_TTL_DAYS | 14 (range 1 to 365) | Entry lifetime. Expiry is lazy, on read. |
Because expiry is lazy, the directory can hold entries past their TTL until they are next read: size the volume for the cache as well as the stores.
Engine: HNSW and cache
[engine]
max_memory_bytes = 25769803776 # 24 GB (default)
vector_dimensions = 1536 # unset = follows CORTEX_EMBEDDING_DIMS; must match it if set
hnsw_m = 16 # default
hnsw_ef_construction = 200 # default
hnsw_ef_search = 100 # default; runtime-tunable
hnsw_tombstone_rebuild_threshold = 0.15 # default; 15% deleted → rebuild
block_cache_bytes = 8589934592 # 8 GB (default)| Field | Default | Range | Tuning |
|---|---|---|---|
max_memory_bytes | 24 GB | ≥ 4 GB | Engine heap budget. Physical RAM minus 4 to 8 GB. |
vector_dimensions | follows CORTEX_EMBEDDING_DIMS | {256, 384, 512, 768, 1024, 1536, 3072} | Must equal the embedding output dim if set. |
hnsw_m | 16 | [4, 64] | Edges per node. Higher = better recall, larger/slower build. |
hnsw_ef_construction | 200 | [10, 2000] | Build candidate pool. |
hnsw_ef_search | 100 | [10, 2000] | Query candidate pool. Higher = better recall, slower queries. |
hnsw_tombstone_rebuild_threshold | 0.15 | [0.0, 1.0] | Rebuild when 15% of nodes are deleted. |
block_cache_bytes | 8 GB | none | RocksDB block cache; affects cold-data read latency. |
Vector quantization
Set it with the environment variable CORTEX_HNSW_QUANTIZATION: tq2 (the default), sq8 (1 byte
per dimension, about 4× less memory than full precision, about 0.5 points less recall) or fp32 (full
precision). GET /v1/admin/metrics shows it under vector_residency.quantization. In cortex.toml,
hnsw_quantization takes only "ScalarU8" or "None", and any other value makes the server ignore the
whole file.
HNSW recipes
| Goal | hnsw_m | ef_construction | ef_search | Quantization |
|---|---|---|---|---|
| Default (used for the published LongMemEval-S 95.4%) | 16 | 200 | 100 | tq2 |
| Voice / realtime | 16 | 200 | 60 | tq2 |
| Memory-constrained | 16 | 200 | 100 | sq8 |
| Max recall accuracy | 32 | 500 | 200 | fp32 |
| Bulk ingest (build fast) | 16 | 100 | 100 | tq2 |
The Max-Recall config buys ~+0.5 to 1 pp at ~3× memory, ~2× build, ~2× query: rarely worth it in production.
Vector index persistence and memory
The HNSW index is snapshotted to the data directory so a restart warms from disk instead of rebuilding.
These are environment variables, not cortex.toml fields; every default below is the value
config_lint reports.
| Env var | Default | What it controls |
|---|---|---|
CORTEX_SNAPSHOT_INTERVAL_SECS | 300 | How often an index snapshot is written. |
CORTEX_SNAPSHOT_KEEP_PREV | 1 | Previous generations kept alongside the current one. |
CORTEX_SNAPSHOT_WRITE_MBPS | 256 | Snapshot write throttle; 0 = unthrottled. |
CORTEX_VECTOR_RESIDENT_MAX | (unset = uncapped) | Hot-tier watermark: how many vectors stay resident in memory. |
CORTEX_EVICT_VECTORS_ON_ENRICH | (unset = off) | Demote vectors during enrichment, for steady-state memory. |
CORTEX_VECTOR_SHARDS | 8 | HNSW shard count. |
CORTEX_SHARD_SEARCH_THREADS | 8 | Per-query chunk fan-out across shards. |
CORTEX_SHARD_SEARCH_POOL | available cores (cap 64) | Search thread-pool size. |
CORTEX_DB_WRITE_BUFFER_MB | 256 (512 for the v1 WAL store) | Per-store RocksDB memtable budget. |
CORTEX_TOTAL_WRITE_BUFFER_MB | (unset = per-store caps only) | Shared memtable budget across stores. |
These snapshots are not backups
CORTEX_SNAPSHOT_* controls vector-index persistence, so that a restart can warm from disk instead
of rebuilding the index. It is not a backup: it captures the index rather than the data directory, and
it is not a recovery point. The supported backup path is the verified cold backup below.
The boot log warns when the hot tier is uncapped
With CORTEX_VECTOR_RESIDENT_MAX unset the hot tier is uncapped, and config_lint computes what the
booting machine can actually hold: reporting bytes-per-vector at the active quantization against
available memory, and recommending a watermark for any corpus that can outgrow it. Set that watermark
(and consider CORTEX_EVICT_VECTORS_ON_ENRICH) before the corpus reaches that size. See
Reading the config_lint dump.
Network and ports
[network]
api_port = 8443 # cortex.toml default
gossip_port = 7000 # default
grpc_port = 9042 # default
request_timeout_ms = 10000 # default (10 s)
gossip_interval_ms = 1000 # default (1 s)| Port | Role | Notes |
|---|---|---|
3141 | v1 API + admin UI (single-node CLI default) | The one public port. |
8443 | api_port from cortex.toml | Cluster-mode binaries (experimental). |
7000 | UDP gossip | Cluster membership (experimental). |
9042 | Internal gRPC RPC | Inter-node calls (experimental). |
Port-defaults gotcha
The single-node CLI defaults --port=3141, while the TOML api_port defaults to 8443. Pick the
value your reverse proxy forwards to and set both consistently.
Scheduler
[scheduler]
enabled = true # default
compaction_interval_secs = 300 # 5 min (min: 30)
methylation_interval_secs = 600 # 10 min (min: 60)
enrichment_drain_interval_secs = 30 # 30 s (min: 5)
cognitive_persist_interval_secs = 60 # 1 min (min: 10)
feedback_weight_interval_secs = 120 # 2 min (min: 30)| Job | Default | What it does |
|---|---|---|
| Compaction | 5 min | Merge/dedupe entries; reduce footprint, improve recall over time. |
| Methylation | 10 min | Decay-adjust salience by access patterns. |
| Enrichment drain | 30 s | Consume async LLM extraction results. |
| Cognitive persist | 1 min | Checkpoint planner state + ranker weights. |
| Feedback weight | 2 min | Apply feedback gradients to ranker weights. |
CORTEX_SCHEDULER_DISABLE=1 disables the whole scheduler at startup (always set for benchmarks). Schema
validation enforces the minimum intervals: a cortex.toml with compaction_interval_secs = 10 is ignored
as a whole (the server logs why and runs on defaults).
Disk and memory guards
Disk. When the data disk passes CORTEX_DISK_WARN_PERCENT (85% by default) and then
CORTEX_DISK_CRITICAL_PERCENT (95%, or less than CORTEX_DISK_CRITICAL_FREE_MB = 4,096 MB free), new
saves get 503 DISK_FULL with Retry-After and background jobs pause. Searches, deletions and erasures
keep working, and saves resume by themselves when space is freed.
Memory. CortexDB sizes its memory use to the machine or container. When memory runs high (on Linux,
CORTEX_MEMORY_PRESSURE=on by default), it turns away heavy work such as bulk imports with
MEMORY_PRESSURE and Retry-After, while single saves, searches, answers and deletions keep working.
It enters the high state at CORTEX_MEMORY_PRESSURE_HIGH (0.85 of the memory limit) and leaves at
CORTEX_MEMORY_PRESSURE_LOW (0.75). With CORTEX_MEMORY_PRESSURE=off nothing turns heavy requests away,
and the kernel may kill the process when memory fills.
Cold storage in your own bucket
When the data disk passes a set level, CortexDB moves its oldest memories into encrypted segment files in
your own bucket. Search still finds them, and erasure and retention still reach them. It's off unless
CORTEX_ICE_URL is set.
| Setting | What it does |
|---|---|
CORTEX_ICE_URL | Where segments go: an s3://, gs:// or az:// bucket, or a local path |
CORTEX_ICE_KEY_FILE | The key that encrypts the segments. Keep it safe: losing it loses the archive |
CORTEX_ICE_KMS_KEY_ID (with _REGION, _ENDPOINT) | Hold the key in AWS KMS instead, so no disk holds it; cortexdb ice-key --kms makes the wrapped key. Disabling the KMS key makes the whole archive unreadable at once |
CORTEX_ICE_TARGET_PERCENT | Seal while the data disk is above this share (75% by default) |
CORTEX_ICE_HOT_DAYS | Keep this many days of memories on fast disk (7 by default); younger rows are sealed only while the disk guard reads warn or critical |
CORTEX_ICE_READ_DEADLINE_MS | The time budget for reading the archive in one search (1,500 ms by default) |
Only memories that are indexed and learned from are sealed. When an archived item can't be read within
the budget, it is left out and the response says so; it is never a silent gap or an error. The trusted
operator can check and steer the store with GET /v1/admin/ice/status, POST /v1/admin/ice/seal (seal
now) and POST /v1/admin/ice/owner (settle a copied data directory that points at the same bucket).
Example: a support team keeps three years of chats: last week on fast disk, the rest in S3, all of it searchable.
Clusters
Plain cortexdb [PORT] [DATA_DIR] serves one node. When one server is not enough, run a cluster:
cortexdb node --config FILE processes, one role each (metadata, data or ingress), built from
the same program, so your code doesn't change.
- Copies of everything. Memory is split into shards, and each shard is kept as 1 to 5 copies on different machines (3 is usual). If the copy in charge fails, another takes over by itself, within seconds. Machines talk over encrypted links; your HTTPS proxy sits in front.
- Entry servers route for you. Ingress nodes send each request to the right shard and retry briefly when the copy in charge changes, so your apps never need the cluster's layout.
- No reads from a copy that is behind. Only the copy in charge answers. A save with
?wait=indexed, or a consistency token, makes sure the next search sees it. - Pay for search once. Only the copy in charge calls the embedding model, once per piece of text, and shares the result with the other copies; learned facts are learned once too.
- Move a tenant. One command moves a tenant to another shard, with its memory ids, retry keys, files and access records; a move can be cancelled, and saves for that tenant pause while it is copied.
- Repair and recovery. Replace a failed copy (the new one catches up by itself) or repair a lost disk. A shard that lost most of its copies can be rebuilt from one copy's backup; saves made after that backup are lost.
- One admin command.
cortexdb admin --config FILEsets up and runs the cluster;cortexdb admin statusprints oneFAILline per problem on any machine, such as a full disk or a clock that is off.
Each data node holds the license itself and takes engine settings in its config's [engine] table. A
cluster is upgraded node by node, one binary per shard. Talk to your CortexDB contact before you plan
one: the cluster guide covers its configuration.
The older cluster flags on plain cortexdb (--node-id other than 1, --rpc-addr, --gossip-addr,
--seed-nodes, --peers, --rf) and any CORTEX_CLUSTER_* variable stop it at startup with
CLUSTER_MODE_UNSUPPORTED (exit 78), before the data directory is created.
Blob storage
Binary content (images, audio, video, documents) is stored in a blob backend with a content-addressed reference in the WAL.
[blob_store]
provider = "local" # "local" | "s3" | "gcs" | "azure"
# Local mode
data_dir = "/data/cortex/blobs"
# S3 mode
bucket = "acme-cortex-blobs"
region = "us-east-1"
endpoint = "" # optional: S3-compatible (R2, MinIO, B2)
access_key_id = "" # falls back to AWS_ACCESS_KEY_ID env
secret_access_key = "" # falls back to AWS_SECRET_ACCESS_KEY env
allow_http = false # true ONLY for MinIO over LAN
virtual_hosted_style_request = true # false for path-style URLs
# S3 encryption
s3_encryption_type = "aws:kms" # "AES256" | "aws:kms" | "" (none)
s3_kms_key_id = "arn:aws:kms:..." # required if s3_encryption_type = aws:kms
s3_bucket_key_enabled = true # KMS bucket key: saves KMS API costsEvery TOML field has an env-var form (e.g. CORTEX_BLOB_BUCKET, CORTEX_BLOB_S3_KMS_KEY_ID); the env
var wins if both are set. GCS uses gcs_bucket + gcs_application_credentials; Azure uses
azure_account + azure_container + azure_access_key (falls back to AZURE_STORAGE_KEY); MinIO is
S3 with endpoint + allow_http = true + virtual_hosted_style_request = false.
Blobs are referenced from /v1/experience payloads by content hash and served via
/v1/blobs/{id}. The server reads/writes the backend transparently:
co-locate CortexDB and the blob backend in the same region/VPC.
Content modality processors
Each modality has its own extraction integration; all are optional: if unconfigured, ingest skips extraction for that modality.
# Image (GPT-4o vision)
export CORTEX_IMAGE_PROVIDER=openai
export CORTEX_IMAGE_API_KEY=$OPENAI_API_KEY
export CORTEX_IMAGE_MODEL=gpt-4o
# Audio (Whisper)
export CORTEX_AUDIO_PROVIDER=openai
export CORTEX_AUDIO_API_KEY=$OPENAI_API_KEY
export CORTEX_AUDIO_MODEL=whisper-1
export CORTEX_AUDIO_LANGUAGE=en # optional
# Video (ffmpeg keyframes → image processor)
export CORTEX_FFMPEG_PATH=ffmpeg
export CORTEX_VIDEO_KEYFRAMES_PER_MIN=6
# Document (OCR / PDF extraction: e.g. Tika)
export CORTEX_DOCUMENT_PROVIDER=...
export CORTEX_DOCUMENT_API_URL=...
export CORTEX_DOCUMENT_API_KEY=...The same fields can be set under [content_processors.image] / .audio / .video / .document /
.sensor. See Media ingestion.
Disk sizing
Rough rule of thumb on text-heavy workloads with text-embedding-3-small (1536 d, tq2 quantization):
| Events stored | Disk footprint | Memory (cache + HNSW) |
|---|---|---|
| 100 K | ~2 GB | ~1 GB |
| 1 M | ~15 GB | ~6 GB |
| 10 M | ~120 GB | ~40 GB |
| 100 M | ~1.1 TB | ~350 GB (cluster) |
Above ~10M events, plan a very large single box, or talk to your CortexDB contact about a cluster. Either way, keep regular verified cold backups and infra-level redundancy (RAID, replicated volumes).
Backups and snapshots
The supported backup is a verified cold backup of the data directory, built into the server. There is no online (hot) backup, scheduled job or point-in-time recovery: stop the server, back up, start it.
# The server must be stopped: the command refuses a data directory in use.
cortexdb backup DATA_DIR ARCHIVE.tar.gz
# Recompute every file digest against the archive's SHA-256 manifest.
cortexdb backup-verify ARCHIVE.tar.gz
# Restore into an empty directory only; a non-empty target or a tampered archive is refused.
cortexdb restore ARCHIVE.tar.gz EMPTY_DIRThe archive holds the whole data directory, with a per-file SHA-256 manifest. See Backups & Disaster Recovery for the full procedure, with Docker.
Next steps
- Configuration Foundations: file/env/CLI precedence
- Security & Compliance: encryption, TLS, RBAC, audit
- Profiles & Presets: the Batch profile for high throughput
Recall Tuning
Every recall-strategy knob: graph retrieval, HyDE, multihop, salience, reranker, and the constants that aren't (yet) configurable.
Retention & WAL Maintenance
Operator-driven expiry of old events and reclamation of dead write-ahead-log rows: per-scope rules, dry-run sweeps, and the WAL census.