Principle:4paradigm OpenMLDB Cluster Scaling
| Knowledge Sources | |
|---|---|
| Domains | Distributed_Systems, Cluster_Operations |
| Last Updated | 2026-10-12 12:00 GMT |
Overview
A cluster resizing methodology that redistributes table partitions across tablet servers to balance load when adding or removing nodes, while maintaining replica consistency.
Description
Cluster scaling in OpenMLDB involves two operations: ScaleOut (adding capacity) and ScaleIn (removing capacity). ScaleOut discovers all healthy tablets and rebalances partition leaders across them by migrating partitions from overloaded tablets to new tablets. ScaleIn removes specified tablets by migrating all their partitions to remaining healthy tablets, ensuring no data loss. Both operations respect replica constraints — a partition cannot be migrated to a tablet that already hosts a replica of the same partition.
The key problem solved is load imbalance: when tablets are added or removed, some tablets may be overloaded while others are underutilized. Scaling redistributes partitions to achieve near-uniform distribution.
Usage
Use this principle when cluster capacity needs to change — adding tablets for increased load or removing tablets for maintenance or cost reduction. Always disable auto-failover before scaling.
Theoretical Basis
Partition balancing targets uniform distribution:
Where |P_i| is the number of partitions on tablet i. The algorithm repeatedly migrates from the most-loaded to the least-loaded tablet until the imbalance is at most 1.
Pseudo-code for scale-out:
# Abstract algorithm (NOT real implementation)
def scale_out(cluster):
healthy_tablets = get_healthy_tablets(cluster)
for db in all_databases(cluster):
partition_map = build_partition_map(db, healthy_tablets)
while max(partition_map) - min(partition_map) > 1:
src = argmax(partition_map) # most loaded
dst = argmin(partition_map) # least loaded
partition = select_migratable(src, dst)
migrate_partition(partition, src, dst)
update_map(partition_map, partition, src, dst)
Practical Guide
- ScaleOut rebalances across all healthy tablets — no endpoints need to be specified
- ScaleIn requires specifying which tablet endpoints to remove via
--endpoints - ScaleIn checks that replica count per partition does not exceed remaining tablet count
- For single-replica tables, ScaleIn adds a temporary replica before migrating the leader
- Use
BalanceInDatabasefor per-database balancing