Skip to content

Scaled Deployment

ModeScaled distributes storage across dedicated backends: Qdrant for vectors, Redis for key-value and event log, and Postgres for the graph store. This enables higher throughput and independent scaling of each component.

Architecture

Configuration

Go SDK

go
db, err := client.Open(client.Options{
    Mode:             client.ModeScaled,
    DSN:              "postgres://user:pass@localhost:5432/contextdb?sslmode=disable",
    QdrantAddr:       "localhost:6334",
    RedisAddr:        "localhost:6379",
    VectorDimensions: 1536,
})
OptionTypeDescription
ModeModeMust be ModeScaled
DSNstringPostgres connection string for graph store
QdrantAddrstringQdrant gRPC address
RedisAddrstringRedis address
VectorDimensionsintEmbedding dimensionality (default: 1536)

Docker Compose

The docker-compose.yml includes a scaled profile with Qdrant and Redis:

bash
docker compose --profile scaled up --build

This starts:

ServicePortPurpose
contextdb7700, 7701gRPC + REST server
postgres5432Graph store with pgvector
qdrant6334Vector index
redis6379KV store + event log

All services have persistent volumes and health checks.

Backend details

Qdrant

The Qdrant backend implements store.VectorIndex:

  • Collections are named contextdb_{namespace} with cosine distance
  • Label filtering is pushed down to Qdrant as metadata filters
  • Vectors are stored with node metadata (ID, namespace, labels)
  • Requires the integration build tag for compilation

Redis

The Redis backend implements store.KVStore and store.EventLog:

  • Keys are prefixed with contextdb:kv: by default
  • TTL is supported via SET ... EX for session data and caches
  • Event log entries are stored in Redis sorted sets

Postgres

Postgres continues to serve as the graph store in scaled mode, providing:

  • Node and edge CRUD with versioning
  • Recursive CTE graph traversal for Walk operations
  • Source credibility tracking

When to use scaled mode

ScenarioRecommended mode
Development and testingEmbedded (in-memory)
Single-node productionStandard (Postgres only)
Multi-service architectureRemote (gRPC client)
High vector throughput, large datasetsScaled
Independent scaling of vector/graph/cacheScaled

Released under the MIT License.