Skip to content

Commit 6d90941

Browse files
committed
kvserver: add LBRebalancingMultiMetric
This commit adds a new option to kvserver.LoadBasedRebalancingMode for the multi-metric allocator. Note that there is a validation check in place to prevent users from enabling it since it is still an unimplemented feature. Epic: none Release note: none
1 parent c23bfbe commit 6d90941

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

docs/generated/settings/settings.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
<tr><td><div id="setting-jobs-retention-time" class="anchored"><code>jobs.retention_time</code></div></td><td>duration</td><td><code>336h0m0s</code></td><td>the amount of time for which records for completed jobs are retained</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
8686
<tr><td><div id="setting-kv-allocator-lease-rebalance-threshold" class="anchored"><code>kv.allocator.lease_rebalance_threshold</code></div></td><td>float</td><td><code>0.05</code></td><td>minimum fraction away from the mean a store&#39;s lease count can be before it is considered for lease-transfers</td><td>Dedicated/Self-Hosted</td></tr>
8787
<tr><td><div id="setting-kv-allocator-load-based-lease-rebalancing-enabled" class="anchored"><code>kv.allocator.load_based_lease_rebalancing.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>set to enable rebalancing of range leases based on load and latency</td><td>Dedicated/Self-Hosted</td></tr>
88-
<tr><td><div id="setting-kv-allocator-load-based-rebalancing" class="anchored"><code>kv.allocator.load_based_rebalancing</code></div></td><td>enumeration</td><td><code>leases and replicas</code></td><td>whether to rebalance based on the distribution of load across stores [off = 0, leases = 1, leases and replicas = 2]</td><td>Dedicated/Self-Hosted</td></tr>
88+
<tr><td><div id="setting-kv-allocator-load-based-rebalancing" class="anchored"><code>kv.allocator.load_based_rebalancing</code></div></td><td>enumeration</td><td><code>leases and replicas</code></td><td>whether to rebalance based on the distribution of load across stores [off = 0, leases = 1, leases and replicas = 2, multi-metric = 3]</td><td>Dedicated/Self-Hosted</td></tr>
8989
<tr><td><div id="setting-kv-allocator-load-based-rebalancing-objective" class="anchored"><code>kv.allocator.load_based_rebalancing.objective</code></div></td><td>enumeration</td><td><code>cpu</code></td><td>what objective does the cluster use to rebalance; if set to `qps` the cluster will attempt to balance qps among stores, if set to `cpu` the cluster will attempt to balance cpu usage among stores [qps = 0, cpu = 1]</td><td>Dedicated/Self-Hosted</td></tr>
9090
<tr><td><div id="setting-kv-allocator-load-based-rebalancing-interval" class="anchored"><code>kv.allocator.load_based_rebalancing_interval</code></div></td><td>duration</td><td><code>1m0s</code></td><td>the rough interval at which each store will check for load-based lease / replica rebalancing opportunities</td><td>Dedicated/Self-Hosted</td></tr>
9191
<tr><td><div id="setting-kv-allocator-qps-rebalance-threshold" class="anchored"><code>kv.allocator.qps_rebalance_threshold</code></div></td><td>float</td><td><code>0.1</code></td><td>minimum fraction away from the mean a store&#39;s QPS (such as queries per second) can be before it is considered overfull or underfull</td><td>Dedicated/Self-Hosted</td></tr>

pkg/kv/kvserver/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ go_library(
219219
"//pkg/util/encoding",
220220
"//pkg/util/envutil",
221221
"//pkg/util/errorutil",
222+
"//pkg/util/errorutil/unimplemented",
222223
"//pkg/util/growstack",
223224
"//pkg/util/grpcutil",
224225
"//pkg/util/grunning",

pkg/kv/kvserver/store_rebalancer.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"github.com/cockroachdb/cockroach/pkg/roachpb"
2020
"github.com/cockroachdb/cockroach/pkg/settings"
2121
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
22+
"github.com/cockroachdb/cockroach/pkg/util/buildutil"
23+
"github.com/cockroachdb/cockroach/pkg/util/errorutil/unimplemented"
2224
"github.com/cockroachdb/cockroach/pkg/util/log"
2325
"github.com/cockroachdb/cockroach/pkg/util/metric"
2426
"github.com/cockroachdb/cockroach/pkg/util/stop"
@@ -69,6 +71,9 @@ func makeStoreRebalancerMetrics() StoreRebalancerMetrics {
6971
}
7072
}
7173

74+
var ErrMultiMetricRebalancingNotSupported = unimplemented.NewWithIssue(
75+
103320, "multi-metric rebalancing not supported for production use")
76+
7277
// LoadBasedRebalancingMode controls whether range rebalancing takes
7378
// additional variables such as write load and disk usage into account.
7479
// If disabled, rebalancing is done purely based on replica count.
@@ -81,8 +86,16 @@ var LoadBasedRebalancingMode = settings.RegisterEnumSetting(
8186
LBRebalancingOff: "off",
8287
LBRebalancingLeasesOnly: "leases",
8388
LBRebalancingLeasesAndReplicas: "leases and replicas",
89+
LBRebalancingMultiMetric: "multi-metric",
8490
},
85-
settings.WithPublic)
91+
settings.WithPublic,
92+
settings.WithValidateEnum(func(enumStr string) error {
93+
if buildutil.CrdbTestBuild || enumStr != "multi-metric" {
94+
return nil
95+
}
96+
return ErrMultiMetricRebalancingNotSupported
97+
}),
98+
)
8699

87100
// LBRebalancingMode controls if and when we do store-level rebalancing
88101
// based on load.
@@ -98,6 +111,10 @@ const (
98111
// LBRebalancingLeasesAndReplicas means that we rebalance both leases and
99112
// replicas based on store-level load imbalances.
100113
LBRebalancingLeasesAndReplicas
114+
// LBRebalancingMultiMetric means that the store rebalancer yields to the
115+
// multi-metric store rebalancer, balancing both leases and replicas based on
116+
// store-level load imbalances.
117+
LBRebalancingMultiMetric
101118
)
102119

103120
// RebalanceSearchOutcome returns the result of a rebalance target search. It

0 commit comments

Comments
 (0)