Docs / Metadata that scales without a master

Metadata that scales without a master

KalDB keeps cluster metadata in ZooKeeper or etcd as one small record per object, so changes stay small as the cluster grows, and indexing and search don't depend on a master node.

KalDB doesn’t have a master node that owns the cluster state. Metadata lives in an external store, ZooKeeper or etcd, as one small record per object. Each node watches only the records it needs, every change touches only a record or two, and indexing and search keep running when the cluster manager is down.

How KalDB keeps cluster metadata small, granular, and off the critical pathKalDB keeps metadata in ZooKeeper or etcd as one small record per object. Each node watches only the records it needs. When an indexer uploads a snapshot it writes one record, and when the cluster manager assigns a replica it writes one record that only the chosen cache node acts on. A classic search cluster instead has an elected master send the whole cluster state to every node on each change. When the KalDB cluster manager goes down, indexing and searches keep running.ZooKeeper or etcdone small record per objectdatasetssnapshotsreplicassearch nodes+1+1datasetssnapshotssearch nodeseverythingown slotsown slotslogsPreprocessorvia KafkaIndexerQueryClustermanagerdownCache 1no changeCache 2loading S7S3upload snapshotNo node holds the whole cluster state. Each one watches only its own records.New snapshot in S3, so the indexer writes one snapshot record. Nothing else changes.One replica record for Cache 2. Only Cache 2 acts on it. Cache 1 never hears about it.Indexing and searches keep running. New snapshots wait for a cache until the manager is back.Classic search clusterElectedmasterwhole cluster state, v812every change goes to every nodegrows with indexes, shards, and fieldsmaster down = the cluster can't change
Metadata Each node watches only the records it needs. One snapshot uploaded, one small record written. One replica assigned. Only Cache 2 reacts. Classic cluster: each change ships the whole cluster state to every node. Cluster manager down. Indexing and searches keep running.

The problem

Elasticsearch and OpenSearch keep all cluster metadata in a single cluster state: every index, mapping, shard, and node. One elected master owns it. On every change, such as a new index, a mapping update, or a shard move, the master builds a new version and publishes it to every node in the cluster.

That works for small clusters and gets harder as they grow. The cluster state grows with every index, shard, and field, so each update takes longer to build and ship, and a busy master becomes the bottleneck for the whole cluster. While no master is elected, the cluster can’t create indexes or move shards. Teams split large deployments into many smaller clusters partly to keep the cluster state manageable.

How it works

  1. Metadata lives outside the data nodes. KalDB stores cluster metadata in ZooKeeper or etcd, which are replicated stores built for exactly this. No KalDB node owns it.
  2. One small record per object. Each dataset, partition, snapshot, replica, cache slot, recovery task, and search node is its own record. The largest sets, such as snapshots, replicas, and cache slots, are split across sub-paths so that no single listing grows too large.
  3. Nodes watch only what they need. Each node keeps a local, cached copy of the records it uses and is told when they change. The preprocessor watches datasets, a cache node watches its own slots, and query nodes watch the list of search nodes and snapshots.
  4. Changes are small and local. When an indexer uploads a snapshot to S3, it writes one snapshot record. When the cluster manager assigns that snapshot to a cache node, it writes one replica record, and only that cache node acts on it.
  5. The manager is off the critical path. The cluster manager creates and assigns replicas, assigns recovery tasks, and cleans up expired data. The preprocessor, indexers, and query nodes don’t go through it. Indexers write their own snapshot records, and indexer and cache nodes register themselves as searchable. If the manager is down, logs keep flowing and searches keep running.

Why it matters

  • Updates stay small as the cluster grows. A change writes one record, not a new version of the whole cluster state, so update cost doesn’t grow with the number of datasets, snapshots, or nodes.
  • No master bottleneck. There is no single node every change has to go through.
  • Fewer, larger clusters. Metadata size isn’t the reason to split a deployment, which is part of how one KalDB cluster can serve many tenants. See Tenant isolation.
  • Proven stores. ZooKeeper and etcd handle replication and leader election for the metadata, so KalDB doesn’t implement its own consensus.

Trade-offs

  • One more system to run. You operate a ZooKeeper or etcd ensemble alongside KalDB, and it needs to be sized and monitored like any other critical dependency.
  • Nodes restart if they lose their session. A short disconnect is retried and nodes keep using their cached records. If a node’s ZooKeeper session expires (zkSessionTimeoutMs, 5 seconds by default), the node exits and is restarted so it rejoins with a fresh view.
  • The manager still matters for new data in cache. While the cluster manager is down, new snapshots are not assigned to cache nodes, recovery tasks wait, and expired data isn’t cleaned up. Indexers keep recent data searchable in the meantime, and the manager catches up from the metadata store when it comes back.

Configuration

Choose the metadata store with metadataStoreConfig.mode. The two BOTH_* modes read from both stores while writing to one, for migrating between ZooKeeper and etcd.

metadataStoreConfig:
  # ZOOKEEPER_EXCLUSIVE, ETCD_EXCLUSIVE,
  # BOTH_READ_ZOOKEEPER_WRITE, or BOTH_READ_ETCD_WRITE
  mode: ZOOKEEPER_EXCLUSIVE
  zookeeperConfig:
    zkConnectString: localhost:2181
    zkPathPrefix: ASTRA
    zkSessionTimeoutMs: 5000
    zkConnectionTimeoutMs: 500
    zkCacheInitTimeoutMs: 30000
    sleepBetweenRetriesMs: 100

Related