Brain Docs
Run

Getting it up

Run it locallyConfiguration

Operating it

ObservabilityBackups and recoverySecurityScaling and limits

Reference

Brain/Docs
✦ ASKBrain on GitHubDashboard
RunScaling and limits

Scaling and limits

Shards are chosen once, tenants are capped at single-shard throughput, and the engine is single-node — the boundaries to know before you build on it.

PURPOSE

Honest boundaries. Better to meet them here than in production.

How it scales today

Thread-per-core, one writer per shard. Each shard owns its arena, WAL, metadata store and indexes, and runs on a dedicated core with io_uring. No locks — the single-writer discipline replaces them. Reads are lock-free.

Shards are assigned by hash, keyed on the space. The routing key is BLAKE3(space_id) % shard_count, resolved at a space's first contact and persisted so the assignment survives a restart. A memory id encodes its shard in its top 16 bits, so routing a forget or a link to a known memory is bit extraction with no lookup at all.

The routing table is immutable after construction and validated there: a shard_count of 0 is rejected, and so is an override pointing at a shard that does not exist. There is no dynamic reconfiguration in v1 — changes require a restart.

That gives predictable tail latency, and it sets the hard limit below.

The limits

Limit
What it means for you
Single node, no replication
No clustering, no followers, no failover
Node loss = restore from snapshot. Plan downtime into your SLO
One space, one shard
Placement is `BLAKE3(space_id) % shard_count`
A single space cannot exceed one shard's throughput, however many shards you run. Splitting a tenant across spaces is the lever
shard_count is fixed
No auto-split, no auto-merge, no online resharding
Changing it rehomes tenants. Decide up front
HNSW is RAM-resident
Memory-hungry past roughly 10⁷ vectors per shard
Size RAM against vector count, not disk
One embedding model, pinned
No in-place migration path
Changing it means a fresh deployment and a full re-ingest
English only
`bge-small-en-v1.5`
Other languages need a different model, so a different deployment

Choosing shard_count

The decision you can't cheaply revisit. Two forces:

  • More shards — more parallelism across tenants, more cores used, smaller per-shard recovery and index.
  • Fewer shards — less memory overhead, fewer background workers.

Start from cores, not from data size. A shard wants a core. Setting shard_count above your core count buys contention, not throughput.

Then check the per-space ceiling. Because a space hashes to one shard, your largest space's write rate must fit inside one shard's capacity. If it does not, no shard count fixes it — the lever is the tenancy split, because a tenant spread across several spaces spreads across several shards.

That is a design input, not just an operational one: see one space per customer before you decide what a space means in your product.

The override pin

There is one escape hatch. The routing table carries a startup-time override map, SpaceId → ShardId, for VIP or extra-large spaces — a way to place a known heavy space deliberately rather than wherever the hash lands it. It is startup-time only, validated at construction, and changing it is a restart. It is not online resharding, and it does not raise the single-space ceiling; it only decides which shard pays it.

Sizing memory

The index is in RAM and the arena is a mapped file:

[shard]
arena_capacity_bytes = "1GiB"

The arena is fixed-size — it doesn't grow on demand. Running out isn't gradual degradation, so alert on brain_arena_slots_free well before it's exhausted. Budget RAM for the HNSW graphs, the lexical index, the embedding model, and the arena pages actually touched.

What's not built

Named plainly, because these are often assumed:

  • Multi-node clustering — distributed coordination, cross-node fan-out.
  • Replication — synchronous WAL streaming or async followers; neither exists.
  • Tenant offloading — cold tenants to object storage.
  • Storage/compute separation.
  • IVF + PQ for billion-vector scale on top of HNSW.
  • Range-based sharding with auto-split.
  • Multi-region.
  • A query language. The wire protocol is typed RPC, not SQL.

These are documented as future directions, not commitments. Don't plan against them.

Is this the right shape for you?

Good fit — many small-to-medium tenants, predictable latency matters, one node is enough, you can tolerate restore-from-snapshot as your failure story.

Bad fit today — HA with automatic failover, one tenant beyond a single shard, billion-vector scale, multi-region, or multilingual in one deployment.

"Pre-release, pre-1.0" is the honest frame. Wire protocol, on-disk formats and the schema model still change in place without compatibility shims, so pin an exact version and read the release notes before upgrading.

Was this page helpful?

Security

Auth is mandatory and fail-closed, identity is never client-claimed, the planes can be split so provider keys never touch the memory process — and what remains yours.

Concepts

Mental models for Brain — typed memory, the write/read pipelines, identity-by-key, the entity graph, and the single-binary architecture.

On this page

How it scales todayThe limitsChoosing shard_countThe override pinSizing memoryWhat's not builtIs this the right shape for you?
Suggest an editOpen in Playground