Skip to main content

Replication Factor and Replica Placement

Kahuna splits keys into partitions. A replica is a copy of one partition stored on one node, and the replication factor is the number of replicas each partition has. By default, Kahuna uses full replication. Each voting node stores all partitions and takes part in the quorum of each partition. This setup is simple, and it remains the default.

A replication factor lets you add nodes for capacity. A new node doesn't need a copy of all partitions. The trade-off is that fault tolerance is counted for each partition. With replication factor 3, each partition tolerates one replica failure, for any node count.

Scaling Past Full Replication​

Full replication has a hard scaling limit. All nodes store all partitions, and each persistent write is copied to all voters of its partition. This means that more nodes can increase coordination cost, and usable storage doesn't increase.

A replication factor removes that limit. Kahuna can replicate each partition to a small quorum and spread different partitions across the cluster. More nodes can then add storage capacity and reduce write amplification for each node. They also give the placement controller more room to distribute load.

For example, with five nodes and replication factor 3, each partition has three replicas and each node hosts only some of the partitions.

In etcd and ZooKeeper, all members store a full copy of the data. In Kahuna, each partition is strongly consistent on its replicas only.

A replication factor alone doesn't give unlimited scale. Other factors also set limits, for example hot keys and network bandwidth.

When to Use It​

Use full replication when the cluster is small or when all nodes must contain a complete copy of all data.

Use a positive replication factor for these goals.

  • Add nodes, but keep the number of copies of each partition the same
  • Reduce disk usage and write amplification per node
  • Keep the Raft quorum for each partition small and predictable
  • Spread partitions across zones or racks

Prefer odd values. Replication factor 3 tolerates one failed replica for a partition. Replication factor 5 tolerates two. Even values usually add cost, and they don't improve failure tolerance.

If the configured replication factor is larger than the current cluster size, Kahuna uses the available voters and can place additional replicas after more nodes join.

Enable a Replication Factor​

For larger clusters, set a replication factor. Each partition is then stored on a smaller replica set.

kahuna-server \
--initial-cluster https://kahuna-1:8082 https://kahuna-2:8082 https://kahuna-3:8082 \
--raft-replication-factor 3 \
--raft-enable-placement-rebalancer

With replication factor 3, each partition has three voter replicas. A node that doesn't host the target partition can also accept the client request and forward it to a hosting replica. This means that clients can connect to any healthy node.

Placement Rebalancer​

Initial placement is applied when a new cluster is bootstrapped with --raft-replication-factor.

The ongoing placement rebalancer has separate settings.

kahuna-server \
--raft-replication-factor 3 \
--raft-enable-placement-rebalancer \
--raft-max-replica-moves-per-pass 2 \
--raft-max-concurrent-replica-repairs 3 \
--raft-max-concurrent-replica-transfers 1

The rebalancer repairs under-replicated partitions and trims over-replicated partitions. It also smooths replica-count skew. It executes on a separate controller interval, --raft-placement-pass-interval, and it doesn't need the leader balancer.

Repair and balance are budgeted separately. Repair moves restore durability after a node leaves or fails and are controlled by --raft-max-concurrent-replica-repairs. Balance moves smooth replica-count skew and are controlled by --raft-max-concurrent-replica-transfers. --raft-max-replica-moves-per-pass caps how many new moves can start during one pass across both priorities.

Replica moves happen in stages. The new replica starts as a learner and is seeded from the Raft log or a partition snapshot.

During a move, a request can receive a retryable response if leadership or hosting changes at the same time. Retrying against the cluster is the normal client behavior.

Decommissioning a Node​

On a placed cluster, a graceful leave drains the node before removing it from the roster. Kahuna first copies the departing node's hosted replicas to survivors, then commits the membership removal.

kahuna-cli \
-c "https://kahuna-1:8082,https://kahuna-2:8082,https://kahuna-3:8082" \
--cluster-leave \
--node "https://kahuna-3:8082"

The leave response includes these fields.

  • left: the node is no longer in the committed roster and can be stopped
  • drained: the node's placed replicas were evacuated before removal
  • outcome: the membership outcome, for example Committed or DrainTimedOut

--raft-decommission-drain-timeout bounds how long the leave waits for evacuation. If it times out, the node remains in the roster, and the replicas that already moved don't move back. A retry resumes the drain.

Evicted (HTTP 503, retryable) means the cluster removed the node as a dead member while its leave request was running. Its replicas were not evacuated. Keep the process running so it can rejoin, then retry the leave; an empty roster entry alone is not confirmation of a completed drain.

Only one drain can be active at a time. A second leave can return RefusedDrainInProgress; remove nodes sequentially during scale-down.

Zones​

Set a zone or rack hint on each node when replicas should be spread across failure domains.

kahuna-server \
--raft-zone rack-a \
--raft-replication-factor 3 \
--raft-enable-placement-rebalancer

The planner prefers distinct zones when it can. Zone hints are advisory. If there aren't enough distinct zones, the cluster uses the available voters.

Inspect Placement​

Use the CLI to inspect the committed placement table.

kahuna-cli -c "https://kahuna-1:8082" --cluster-placement
kahuna-cli -c "https://kahuna-1:8082" --cluster-placement --format json

The output shows this information.

  • Global replication factor
  • Whether the placement rebalancer is enabled
  • Which partitions the contacted node hosts locally
  • Each partition's lifecycle state and generation
  • Each partition's effective replication factor
  • Replica endpoints and roles

Replicas have three roles.

RoleMeaning
VoterStores the partition and votes in that partition's quorum.
LearnerCatching up before promotion.
RemovingPresent while the cluster completes a safe removal.

An empty replica set means full replication for that partition: all roster voters host it.

The same information is available through the REST API.

GET /v1/cluster/placement

Override One Partition​

You can override the target replication factor for one partition.

kahuna-cli \
-c "https://kahuna-1:8082,https://kahuna-2:8082,https://kahuna-3:8082" \
--set-replication-factor 5 \
--partition 3

Use 0 to clear the override and return to the global replication factor.

kahuna-cli -c "https://kahuna-1:8082" \
--set-replication-factor 0 \
--partition 3

The override commits a new placement target. Replica movement happens later through the placement rebalancer.

This REST endpoint sets the override.

POST /v1/cluster/replication-factor
Content-Type: application/json

{"partitionId":3,"replicationFactor":5}

Readiness​

GET /v1/cluster/health includes hostedPartitions, the number of data partitions hosted by the node answering the request.

Treat hostedPartitions as informational only. With per-partition placement, a healthy node can host zero data partitions. It can also serve requests by forwarding them to hosting replicas.

Backups​

Use a coordinated backup for whole-cluster coverage under replica placement: it composes one share per hosting source at a common cut into a complete backup. A full backup that isn't coordinated is node-local and can omit partitions hosted elsewhere. For the version requirement and coverage validation, see Replica Placement Coverage. For retry behavior, see Capture Cost and Lagging Replicas.

Migration Notes​

Follow these steps to move an existing fully replicated cluster to a replication factor.

  1. Enable a positive replication factor and the placement rebalancer (--raft-replication-factor and --raft-enable-placement-rebalancer).
  2. The server first gives each fully replicated partition an explicit replica set of all committed roster voters. This means that the existing quorum is preserved. It then trims surplus replicas one step at a time toward the target, within the per-pass move limit.
  3. Follow progress with --cluster-placement. On the partition 0 leader, the raft.placement.ranges_awaiting_initial gauge reaches zero when assignment finishes; trimming and movement can continue after that.

If rebalancing is disabled, the partitions remain fully replicated, and a warning explains why conversion hasn't started. More nodes then add copies. They don't distribute the data. Old server versions that don't support conversion require their earlier migration procedure.

If a learner added by placement isn't promoted, --raft-learner-promotion-stall-warning-after (30,000 ms) logs the last failed promotion check. For conversion and promotion details, see Replica Placement Internals.

Snapshot Receive Capacity​

A learner below retained history receives a whole-partition snapshot. Size the snapshot receive caps and staging directory for your largest partition; see Snapshot Options for the settings and partial-install limitations.

Kubernetes​

For Kubernetes deployment and traffic-driven node counts, use the Kubernetes Operator. It combines placement with roster-gated changes. The server performs eligible legacy conversion; the operator can hold growth while that placement remains pending. Automatic PITR seeding of new pods remains a separate workflow.

Dead-Member Eviction​

--raft-dead-member-eviction-grace now defaults to 600,000 ms (10 minutes), matching Kommander. It begins after the failure detector marks a member Dead; it is separate from ping and suspicion timeouts. Embedded hosts use the nullable RaftDeadMemberEvictionGrace option. If you don't set it, the default is the same.

Size this grace for outages the roster should tolerate intact. An evicted node rejoins as a learner and must catch up before voting again. In a three-voter cluster, removing a temporarily paused node can leave only two voters during its rejoin; another pause can then stop quorum progress. Clusters with spare nodes can instead repair placed replicas elsewhere. The system-partition leader warns once per minute while evicted members leave the roster short; use that signal alongside catch-up and placement status.