-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
Copy pathreplica_split_load.go
40 lines (34 loc) · 1.46 KB
/
replica_split_load.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2019 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
package storage
import "github.com/cockroachdb/cockroach/pkg/settings"
// SplitByLoadEnabled wraps "kv.range_split.by_load_enabled".
var SplitByLoadEnabled = settings.RegisterBoolSetting(
"kv.range_split.by_load_enabled",
"allow automatic splits of ranges based on where load is concentrated",
true,
)
// SplitByLoadQPSThreshold wraps "kv.range_split.load_qps_threshold".
var SplitByLoadQPSThreshold = settings.RegisterIntSetting(
"kv.range_split.load_qps_threshold",
"the QPS over which, the range becomes a candidate for load based splitting",
2500, // 2500 req/s
)
// SplitByLoadQPSThreshold returns the QPS request rate for a given replica.
func (r *Replica) SplitByLoadQPSThreshold() float64 {
return float64(SplitByLoadQPSThreshold.Get(&r.store.cfg.Settings.SV))
}
// SplitByLoadEnabled returns whether load based splitting is enabled.
// Although this is a method of *Replica, the configuration is really global,
// shared across all stores.
func (r *Replica) SplitByLoadEnabled() bool {
return SplitByLoadEnabled.Get(&r.store.cfg.Settings.SV) &&
!r.store.TestingKnobs().DisableLoadBasedSplitting
}