2022-09-16 09:56:47 +08:00
// Licensed to the LF AI & Data foundation under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package paramtable
import (
2022-10-27 17:37:32 +08:00
"fmt"
2022-09-16 09:56:47 +08:00
"math"
2022-12-07 18:01:19 +08:00
"strconv"
2022-09-16 09:56:47 +08:00
"go.uber.org/zap"
2023-04-06 19:14:32 +08:00
"github.com/milvus-io/milvus/pkg/log"
2022-09-16 09:56:47 +08:00
)
const (
// defaultMax is the default unlimited rate or threshold.
2022-10-31 20:59:34 +08:00
defaultMax = float64 ( math . MaxFloat64 )
2022-10-17 16:23:25 +08:00
// MBSize used to convert megabytes and bytes.
MBSize = 1024.0 * 1024.0
// defaultDiskQuotaInMB is the default disk quota in megabytes.
defaultDiskQuotaInMB = defaultMax / MBSize
2022-10-12 10:03:22 +08:00
// defaultMin is the default minimal rate.
2022-09-16 09:56:47 +08:00
defaultMin = float64 ( 0 )
// defaultLowWaterLevel is the default memory low water level.
2022-10-09 14:30:58 +08:00
defaultLowWaterLevel = float64 ( 0.85 )
2022-09-16 09:56:47 +08:00
// defaultHighWaterLevel is the default memory low water level.
2022-10-09 14:30:58 +08:00
defaultHighWaterLevel = float64 ( 0.95 )
2022-09-16 09:56:47 +08:00
)
// quotaConfig is configuration for quota and limitations.
type quotaConfig struct {
2022-12-16 15:59:23 +08:00
QuotaAndLimitsEnabled ParamItem ` refreshable:"false" `
QuotaCenterCollectInterval ParamItem ` refreshable:"false" `
2022-09-16 09:56:47 +08:00
// ddl
2022-12-16 15:59:23 +08:00
DDLLimitEnabled ParamItem ` refreshable:"true" `
2023-02-01 16:03:51 +08:00
DDLCollectionRate ParamItem ` refreshable:"true" `
DDLPartitionRate ParamItem ` refreshable:"true" `
2022-10-09 14:30:58 +08:00
2022-12-16 15:59:23 +08:00
IndexLimitEnabled ParamItem ` refreshable:"true" `
2023-02-01 16:03:51 +08:00
MaxIndexRate ParamItem ` refreshable:"true" `
2022-12-16 15:59:23 +08:00
FlushLimitEnabled ParamItem ` refreshable:"true" `
2023-02-01 16:03:51 +08:00
MaxFlushRate ParamItem ` refreshable:"true" `
2022-12-16 15:59:23 +08:00
CompactionLimitEnabled ParamItem ` refreshable:"true" `
2023-02-01 16:03:51 +08:00
MaxCompactionRate ParamItem ` refreshable:"true" `
2022-09-16 09:56:47 +08:00
// dml
2023-05-12 18:13:26 +08:00
DMLLimitEnabled ParamItem ` refreshable:"true" `
DMLMaxInsertRate ParamItem ` refreshable:"true" `
DMLMinInsertRate ParamItem ` refreshable:"true" `
2023-07-11 11:20:34 +08:00
DMLMaxUpsertRate ParamItem ` refreshable:"true" `
DMLMinUpsertRate ParamItem ` refreshable:"true" `
2023-05-12 18:13:26 +08:00
DMLMaxDeleteRate ParamItem ` refreshable:"true" `
DMLMinDeleteRate ParamItem ` refreshable:"true" `
DMLMaxBulkLoadRate ParamItem ` refreshable:"true" `
DMLMinBulkLoadRate ParamItem ` refreshable:"true" `
DMLMaxInsertRatePerCollection ParamItem ` refreshable:"true" `
DMLMinInsertRatePerCollection ParamItem ` refreshable:"true" `
2023-07-11 11:20:34 +08:00
DMLMaxUpsertRatePerCollection ParamItem ` refreshable:"true" `
DMLMinUpsertRatePerCollection ParamItem ` refreshable:"true" `
2023-05-12 18:13:26 +08:00
DMLMaxDeleteRatePerCollection ParamItem ` refreshable:"true" `
DMLMinDeleteRatePerCollection ParamItem ` refreshable:"true" `
DMLMaxBulkLoadRatePerCollection ParamItem ` refreshable:"true" `
DMLMinBulkLoadRatePerCollection ParamItem ` refreshable:"true" `
2022-09-16 09:56:47 +08:00
// dql
2023-05-12 18:13:26 +08:00
DQLLimitEnabled ParamItem ` refreshable:"true" `
DQLMaxSearchRate ParamItem ` refreshable:"true" `
DQLMinSearchRate ParamItem ` refreshable:"true" `
DQLMaxQueryRate ParamItem ` refreshable:"true" `
DQLMinQueryRate ParamItem ` refreshable:"true" `
DQLMaxSearchRatePerCollection ParamItem ` refreshable:"true" `
DQLMinSearchRatePerCollection ParamItem ` refreshable:"true" `
DQLMaxQueryRatePerCollection ParamItem ` refreshable:"true" `
DQLMinQueryRatePerCollection ParamItem ` refreshable:"true" `
2022-09-16 09:56:47 +08:00
// limits
2023-04-28 11:02:35 +08:00
MaxCollectionNum ParamItem ` refreshable:"true" `
MaxCollectionNumPerDB ParamItem ` refreshable:"true" `
2023-06-07 10:38:36 +08:00
TopKLimit ParamItem ` refreshable:"true" `
NQLimit ParamItem ` refreshable:"true" `
2023-06-25 14:42:43 +08:00
MaxQueryResultWindow ParamItem ` refreshable:"true" `
2023-08-10 14:11:15 +08:00
MaxOutputSize ParamItem ` refreshable:"true" `
2022-09-16 09:56:47 +08:00
2022-09-26 16:48:53 +08:00
// limit writing
2023-05-17 09:57:22 +08:00
ForceDenyWriting ParamItem ` refreshable:"true" `
TtProtectionEnabled ParamItem ` refreshable:"true" `
MaxTimeTickDelay ParamItem ` refreshable:"true" `
MemProtectionEnabled ParamItem ` refreshable:"true" `
DataNodeMemoryLowWaterLevel ParamItem ` refreshable:"true" `
DataNodeMemoryHighWaterLevel ParamItem ` refreshable:"true" `
QueryNodeMemoryLowWaterLevel ParamItem ` refreshable:"true" `
QueryNodeMemoryHighWaterLevel ParamItem ` refreshable:"true" `
GrowingSegmentsSizeProtectionEnabled ParamItem ` refreshable:"true" `
2023-08-08 12:43:07 +08:00
GrowingSegmentsSizeMinRateRatio ParamItem ` refreshable:"true" `
2023-05-17 09:57:22 +08:00
GrowingSegmentsSizeLowWaterLevel ParamItem ` refreshable:"true" `
GrowingSegmentsSizeHighWaterLevel ParamItem ` refreshable:"true" `
DiskProtectionEnabled ParamItem ` refreshable:"true" `
DiskQuota ParamItem ` refreshable:"true" `
DiskQuotaPerCollection ParamItem ` refreshable:"true" `
2022-09-16 09:56:47 +08:00
2022-09-26 16:48:53 +08:00
// limit reading
2022-12-16 15:59:23 +08:00
ForceDenyReading ParamItem ` refreshable:"true" `
QueueProtectionEnabled ParamItem ` refreshable:"true" `
NQInQueueThreshold ParamItem ` refreshable:"true" `
QueueLatencyThreshold ParamItem ` refreshable:"true" `
ResultProtectionEnabled ParamItem ` refreshable:"true" `
MaxReadResultRate ParamItem ` refreshable:"true" `
CoolOffSpeed ParamItem ` refreshable:"true" `
2022-09-16 09:56:47 +08:00
}
func ( p * quotaConfig ) init ( base * BaseTable ) {
2022-12-07 18:01:19 +08:00
p . QuotaAndLimitsEnabled = ParamItem {
Key : "quotaAndLimits.enabled" ,
Version : "2.2.0" ,
DefaultValue : "false" ,
2023-02-23 11:37:46 +08:00
Doc : "`true` to enable quota and limits, `false` to disable." ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . QuotaAndLimitsEnabled . Init ( base . mgr )
const defaultInterval = "3.0"
p . QuotaCenterCollectInterval = ParamItem {
Key : "quotaAndLimits.quotaCenterCollectInterval" ,
Version : "2.2.0" ,
DefaultValue : defaultInterval ,
Formatter : func ( v string ) string {
// (0 ~ 65536)
if getAsInt ( v ) <= 0 || getAsInt ( v ) >= 65536 {
return defaultInterval
}
return v
} ,
2023-02-23 11:37:46 +08:00
Doc : ` quotaCenterCollectInterval is the time interval that quotaCenter
collects metrics from Proxies , Query cluster and Data cluster .
seconds , ( 0 ~ 65536 ) ` ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . QuotaCenterCollectInterval . Init ( base . mgr )
2022-09-16 09:56:47 +08:00
2022-09-26 16:48:53 +08:00
// ddl
2022-12-07 18:01:19 +08:00
max := fmt . Sprintf ( "%f" , defaultMax )
min := fmt . Sprintf ( "%f" , defaultMin )
p . DDLLimitEnabled = ParamItem {
Key : "quotaAndLimits.ddl.enabled" ,
Version : "2.2.0" ,
DefaultValue : "false" ,
2023-02-23 11:37:46 +08:00
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . DDLLimitEnabled . Init ( base . mgr )
p . DDLCollectionRate = ParamItem {
Key : "quotaAndLimits.ddl.collectionRate" ,
Version : "2.2.0" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . DDLLimitEnabled . GetAsBool ( ) {
return max
}
// [0 ~ Inf)
if getAsInt ( v ) < 0 {
return max
}
return v
} ,
2023-02-23 11:37:46 +08:00
Doc : "qps, default no limit, rate for CreateCollection, DropCollection, LoadCollection, ReleaseCollection" ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . DDLCollectionRate . Init ( base . mgr )
p . DDLPartitionRate = ParamItem {
Key : "quotaAndLimits.ddl.partitionRate" ,
Version : "2.2.0" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . DDLLimitEnabled . GetAsBool ( ) {
return max
}
// [0 ~ Inf)
if getAsInt ( v ) < 0 {
return max
}
return v
} ,
2023-02-23 11:37:46 +08:00
Doc : "qps, default no limit, rate for CreatePartition, DropPartition, LoadPartition, ReleasePartition" ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . DDLPartitionRate . Init ( base . mgr )
p . IndexLimitEnabled = ParamItem {
Key : "quotaAndLimits.indexRate.enabled" ,
Version : "2.2.0" ,
DefaultValue : "false" ,
2023-02-23 11:37:46 +08:00
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . IndexLimitEnabled . Init ( base . mgr )
p . MaxIndexRate = ParamItem {
Key : "quotaAndLimits.indexRate.max" ,
Version : "2.2.0" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . IndexLimitEnabled . GetAsBool ( ) {
return max
}
// [0 ~ Inf)
if getAsFloat ( v ) < 0 {
return max
}
return v
} ,
2023-02-23 11:37:46 +08:00
Doc : "qps, default no limit, rate for CreateIndex, DropIndex" ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . MaxIndexRate . Init ( base . mgr )
p . FlushLimitEnabled = ParamItem {
Key : "quotaAndLimits.flushRate.enabled" ,
Version : "2.2.0" ,
DefaultValue : "false" ,
2023-02-23 11:37:46 +08:00
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . FlushLimitEnabled . Init ( base . mgr )
p . MaxFlushRate = ParamItem {
Key : "quotaAndLimits.flushRate.max" ,
Version : "2.2.0" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . FlushLimitEnabled . GetAsBool ( ) {
return max
}
// [0 ~ Inf)
if getAsInt ( v ) < 0 {
return max
}
return v
} ,
2023-02-23 11:37:46 +08:00
Doc : "qps, default no limit, rate for flush" ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . MaxFlushRate . Init ( base . mgr )
p . CompactionLimitEnabled = ParamItem {
Key : "quotaAndLimits.compactionRate.enabled" ,
Version : "2.2.0" ,
DefaultValue : "false" ,
2023-02-23 11:37:46 +08:00
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . CompactionLimitEnabled . Init ( base . mgr )
p . MaxCompactionRate = ParamItem {
Key : "quotaAndLimits.compactionRate.max" ,
Version : "2.2.0" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . CompactionLimitEnabled . GetAsBool ( ) {
return max
}
// [0 ~ Inf)
if getAsInt ( v ) < 0 {
return max
}
return v
} ,
2023-02-23 11:37:46 +08:00
Doc : "qps, default no limit, rate for manualCompaction" ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . MaxCompactionRate . Init ( base . mgr )
2022-09-16 09:56:47 +08:00
2022-09-26 16:48:53 +08:00
// dml
2022-12-07 18:01:19 +08:00
p . DMLLimitEnabled = ParamItem {
Key : "quotaAndLimits.dml.enabled" ,
Version : "2.2.0" ,
DefaultValue : "false" ,
2023-02-23 11:37:46 +08:00
Doc : ` dml limit rates , default no limit .
The maximum rate will not be greater than ` + "max" + ` . ` ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . DMLLimitEnabled . Init ( base . mgr )
p . DMLMaxInsertRate = ParamItem {
Key : "quotaAndLimits.dml.insertRate.max" ,
Version : "2.2.0" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . DMLLimitEnabled . GetAsBool ( ) {
return max
}
2023-06-07 10:38:36 +08:00
rate := getAsFloat ( v )
2023-05-12 18:13:26 +08:00
if math . Abs ( rate - defaultMax ) > 0.001 { // maxRate != defaultMax
rate = megaBytes2Bytes ( rate )
2022-12-07 18:01:19 +08:00
}
// [0, inf)
2023-05-12 18:13:26 +08:00
if rate < 0 {
2022-12-07 18:01:19 +08:00
return max
}
2023-05-12 18:13:26 +08:00
return fmt . Sprintf ( "%f" , rate )
2022-12-07 18:01:19 +08:00
} ,
2023-02-23 11:37:46 +08:00
Doc : "MB/s, default no limit" ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . DMLMaxInsertRate . Init ( base . mgr )
p . DMLMinInsertRate = ParamItem {
Key : "quotaAndLimits.dml.insertRate.min" ,
Version : "2.2.0" ,
DefaultValue : min ,
Formatter : func ( v string ) string {
if ! p . DMLLimitEnabled . GetAsBool ( ) {
return min
}
rate := megaBytes2Bytes ( getAsFloat ( v ) )
// [0, inf)
if rate < 0 {
return min
}
2023-05-12 18:13:26 +08:00
if ! p . checkMinMaxLegal ( rate , p . DMLMaxInsertRate . GetAsFloat ( ) ) {
2022-12-07 18:01:19 +08:00
return min
}
2023-05-12 18:13:26 +08:00
return fmt . Sprintf ( "%f" , rate )
2022-12-07 18:01:19 +08:00
} ,
}
p . DMLMinInsertRate . Init ( base . mgr )
2023-05-12 18:13:26 +08:00
p . DMLMaxInsertRatePerCollection = ParamItem {
Key : "quotaAndLimits.dml.insertRate.collection.max" ,
Version : "2.2.9" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . DMLLimitEnabled . GetAsBool ( ) {
return max
}
2023-06-07 10:38:36 +08:00
rate := getAsFloat ( v )
2023-05-12 18:13:26 +08:00
if math . Abs ( rate - defaultMax ) > 0.001 { // maxRate != defaultMax
rate = megaBytes2Bytes ( rate )
}
// [0, inf)
if rate < 0 {
2023-05-31 16:47:29 +08:00
return p . DMLMaxInsertRate . GetValue ( )
2023-05-12 18:13:26 +08:00
}
return fmt . Sprintf ( "%f" , rate )
} ,
Doc : "MB/s, default no limit" ,
Export : true ,
}
p . DMLMaxInsertRatePerCollection . Init ( base . mgr )
p . DMLMinInsertRatePerCollection = ParamItem {
Key : "quotaAndLimits.dml.insertRate.collection.min" ,
Version : "2.2.9" ,
DefaultValue : min ,
Formatter : func ( v string ) string {
if ! p . DMLLimitEnabled . GetAsBool ( ) {
return min
}
rate := megaBytes2Bytes ( getAsFloat ( v ) )
// [0, inf)
if rate < 0 {
return min
}
if ! p . checkMinMaxLegal ( rate , p . DMLMaxInsertRatePerCollection . GetAsFloat ( ) ) {
return min
}
return fmt . Sprintf ( "%f" , rate )
} ,
}
p . DMLMinInsertRatePerCollection . Init ( base . mgr )
2023-07-11 11:20:34 +08:00
p . DMLMaxUpsertRate = ParamItem {
Key : "quotaAndLimits.dml.upsertRate.max" ,
Version : "2.3.0" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . DMLLimitEnabled . GetAsBool ( ) {
return max
}
rate := getAsFloat ( v )
if math . Abs ( rate - defaultMax ) > 0.001 { // maxRate != defaultMax
rate = megaBytes2Bytes ( rate )
}
// [0, inf)
if rate < 0 {
return max
}
return fmt . Sprintf ( "%f" , rate )
} ,
Doc : "MB/s, default no limit" ,
Export : true ,
}
p . DMLMaxUpsertRate . Init ( base . mgr )
p . DMLMinUpsertRate = ParamItem {
Key : "quotaAndLimits.dml.UpsertRate.min" ,
Version : "2.3.0" ,
DefaultValue : min ,
Formatter : func ( v string ) string {
if ! p . DMLLimitEnabled . GetAsBool ( ) {
return min
}
rate := megaBytes2Bytes ( getAsFloat ( v ) )
// [0, inf)
if rate < 0 {
return min
}
if ! p . checkMinMaxLegal ( rate , p . DMLMaxUpsertRate . GetAsFloat ( ) ) {
return min
}
return fmt . Sprintf ( "%f" , rate )
} ,
}
p . DMLMinUpsertRate . Init ( base . mgr )
p . DMLMaxUpsertRatePerCollection = ParamItem {
Key : "quotaAndLimits.dml.upsertRate.collection.max" ,
Version : "2.3.0" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . DMLLimitEnabled . GetAsBool ( ) {
return max
}
rate := getAsFloat ( v )
if math . Abs ( rate - defaultMax ) > 0.001 { // maxRate != defaultMax
rate = megaBytes2Bytes ( rate )
}
// [0, inf)
if rate < 0 {
return p . DMLMaxUpsertRate . GetValue ( )
}
return fmt . Sprintf ( "%f" , rate )
} ,
Doc : "MB/s, default no limit" ,
Export : true ,
}
p . DMLMaxUpsertRatePerCollection . Init ( base . mgr )
p . DMLMinUpsertRatePerCollection = ParamItem {
Key : "quotaAndLimits.dml.upsertRate.collection.min" ,
Version : "2.3.0" ,
DefaultValue : min ,
Formatter : func ( v string ) string {
if ! p . DMLLimitEnabled . GetAsBool ( ) {
return min
}
rate := megaBytes2Bytes ( getAsFloat ( v ) )
// [0, inf)
if rate < 0 {
return min
}
if ! p . checkMinMaxLegal ( rate , p . DMLMaxUpsertRatePerCollection . GetAsFloat ( ) ) {
return min
}
return fmt . Sprintf ( "%f" , rate )
} ,
}
p . DMLMinUpsertRatePerCollection . Init ( base . mgr )
2022-12-07 18:01:19 +08:00
p . DMLMaxDeleteRate = ParamItem {
Key : "quotaAndLimits.dml.deleteRate.max" ,
Version : "2.2.0" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . DMLLimitEnabled . GetAsBool ( ) {
return max
}
rate := getAsFloat ( v )
if math . Abs ( rate - defaultMax ) > 0.001 { // maxRate != defaultMax
2023-05-12 18:13:26 +08:00
rate = megaBytes2Bytes ( rate )
2022-12-07 18:01:19 +08:00
}
// [0, inf)
if rate < 0 {
return max
}
2023-05-12 18:13:26 +08:00
return fmt . Sprintf ( "%f" , rate )
2022-12-07 18:01:19 +08:00
} ,
2023-02-23 11:37:46 +08:00
Doc : "MB/s, default no limit" ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . DMLMaxDeleteRate . Init ( base . mgr )
p . DMLMinDeleteRate = ParamItem {
Key : "quotaAndLimits.dml.deleteRate.min" ,
Version : "2.2.0" ,
DefaultValue : min ,
Formatter : func ( v string ) string {
if ! p . DMLLimitEnabled . GetAsBool ( ) {
return min
}
rate := megaBytes2Bytes ( getAsFloat ( v ) )
// [0, inf)
if rate < 0 {
return min
}
2023-05-12 18:13:26 +08:00
if ! p . checkMinMaxLegal ( rate , p . DMLMaxDeleteRate . GetAsFloat ( ) ) {
2022-12-07 18:01:19 +08:00
return min
}
2023-05-12 18:13:26 +08:00
return fmt . Sprintf ( "%f" , rate )
2022-12-07 18:01:19 +08:00
} ,
}
p . DMLMinDeleteRate . Init ( base . mgr )
2023-05-12 18:13:26 +08:00
p . DMLMaxDeleteRatePerCollection = ParamItem {
Key : "quotaAndLimits.dml.deleteRate.collection.max" ,
Version : "2.2.9" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . DMLLimitEnabled . GetAsBool ( ) {
return max
}
rate := getAsFloat ( v )
if math . Abs ( rate - defaultMax ) > 0.001 { // maxRate != defaultMax
rate = megaBytes2Bytes ( rate )
}
// [0, inf)
if rate < 0 {
2023-05-31 16:47:29 +08:00
return p . DMLMaxDeleteRate . GetValue ( )
2023-05-12 18:13:26 +08:00
}
return fmt . Sprintf ( "%f" , rate )
} ,
Doc : "MB/s, default no limit" ,
Export : true ,
}
p . DMLMaxDeleteRatePerCollection . Init ( base . mgr )
p . DMLMinDeleteRatePerCollection = ParamItem {
Key : "quotaAndLimits.dml.deleteRate.collection.min" ,
Version : "2.2.9" ,
DefaultValue : min ,
Formatter : func ( v string ) string {
if ! p . DMLLimitEnabled . GetAsBool ( ) {
return min
}
rate := megaBytes2Bytes ( getAsFloat ( v ) )
// [0, inf)
if rate < 0 {
return min
}
if ! p . checkMinMaxLegal ( rate , p . DMLMaxDeleteRatePerCollection . GetAsFloat ( ) ) {
return min
}
return fmt . Sprintf ( "%f" , rate )
} ,
}
p . DMLMinDeleteRatePerCollection . Init ( base . mgr )
2022-12-07 18:01:19 +08:00
p . DMLMaxBulkLoadRate = ParamItem {
Key : "quotaAndLimits.dml.bulkLoadRate.max" ,
Version : "2.2.0" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . DMLLimitEnabled . GetAsBool ( ) {
return max
}
rate := getAsFloat ( v )
if math . Abs ( rate - defaultMax ) > 0.001 { // maxRate != defaultMax
2023-05-12 18:13:26 +08:00
rate = megaBytes2Bytes ( rate )
2022-12-07 18:01:19 +08:00
}
// [0, inf)
if rate < 0 {
return max
}
2023-05-12 18:13:26 +08:00
return fmt . Sprintf ( "%f" , rate )
2022-12-07 18:01:19 +08:00
} ,
2023-02-23 11:37:46 +08:00
Doc : "MB/s, default no limit, not support yet. TODO: limit bulkLoad rate" ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . DMLMaxBulkLoadRate . Init ( base . mgr )
p . DMLMinBulkLoadRate = ParamItem {
Key : "quotaAndLimits.dml.bulkLoadRate.min" ,
Version : "2.2.0" ,
DefaultValue : min ,
Formatter : func ( v string ) string {
if ! p . DMLLimitEnabled . GetAsBool ( ) {
return min
}
rate := megaBytes2Bytes ( getAsFloat ( v ) )
// [0, inf)
if rate < 0 {
return min
}
2023-05-12 18:13:26 +08:00
if ! p . checkMinMaxLegal ( rate , p . DMLMaxBulkLoadRate . GetAsFloat ( ) ) {
2022-12-07 18:01:19 +08:00
return min
}
2023-05-12 18:13:26 +08:00
return fmt . Sprintf ( "%f" , rate )
2022-12-07 18:01:19 +08:00
} ,
}
p . DMLMinBulkLoadRate . Init ( base . mgr )
2022-09-16 09:56:47 +08:00
2023-05-12 18:13:26 +08:00
p . DMLMaxBulkLoadRatePerCollection = ParamItem {
Key : "quotaAndLimits.dml.bulkLoadRate.collection.max" ,
Version : "2.2.9" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . DMLLimitEnabled . GetAsBool ( ) {
return max
}
rate := getAsFloat ( v )
if math . Abs ( rate - defaultMax ) > 0.001 { // maxRate != defaultMax
rate = megaBytes2Bytes ( rate )
}
// [0, inf)
if rate < 0 {
2023-05-31 16:47:29 +08:00
return p . DMLMaxBulkLoadRate . GetValue ( )
2023-05-12 18:13:26 +08:00
}
return fmt . Sprintf ( "%f" , rate )
} ,
Doc : "MB/s, default no limit, not support yet. TODO: limit collection bulkLoad rate" ,
Export : true ,
}
p . DMLMaxBulkLoadRatePerCollection . Init ( base . mgr )
p . DMLMinBulkLoadRatePerCollection = ParamItem {
Key : "quotaAndLimits.dml.bulkLoadRate.collection.min" ,
Version : "2.2.9" ,
DefaultValue : min ,
Formatter : func ( v string ) string {
if ! p . DMLLimitEnabled . GetAsBool ( ) {
return min
}
rate := megaBytes2Bytes ( getAsFloat ( v ) )
// [0, inf)
if rate < 0 {
return min
}
if ! p . checkMinMaxLegal ( rate , p . DMLMaxBulkLoadRatePerCollection . GetAsFloat ( ) ) {
return min
}
return fmt . Sprintf ( "%f" , rate )
} ,
}
p . DMLMinBulkLoadRatePerCollection . Init ( base . mgr )
2022-09-26 16:48:53 +08:00
// dql
2022-12-07 18:01:19 +08:00
p . DQLLimitEnabled = ParamItem {
Key : "quotaAndLimits.dql.enabled" ,
Version : "2.2.0" ,
DefaultValue : "false" ,
2023-02-23 11:37:46 +08:00
Doc : ` dql limit rates , default no limit .
The maximum rate will not be greater than ` + "max" + ` . ` ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . DQLLimitEnabled . Init ( base . mgr )
p . DQLMaxSearchRate = ParamItem {
Key : "quotaAndLimits.dql.searchRate.max" ,
Version : "2.2.0" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . DQLLimitEnabled . GetAsBool ( ) {
return max
}
// [0, inf)
if getAsFloat ( v ) < 0 {
return max
}
return v
} ,
2023-02-23 11:37:46 +08:00
Doc : "vps (vectors per second), default no limit" ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . DQLMaxSearchRate . Init ( base . mgr )
p . DQLMinSearchRate = ParamItem {
Key : "quotaAndLimits.dql.searchRate.min" ,
Version : "2.2.0" ,
DefaultValue : min ,
Formatter : func ( v string ) string {
if ! p . DQLLimitEnabled . GetAsBool ( ) {
return min
}
rate := getAsFloat ( v )
// [0, inf)
if rate < 0 {
return min
}
2023-05-12 18:13:26 +08:00
if ! p . checkMinMaxLegal ( rate , p . DQLMaxSearchRate . GetAsFloat ( ) ) {
2022-12-07 18:01:19 +08:00
return min
}
return v
} ,
}
p . DQLMinSearchRate . Init ( base . mgr )
2023-05-12 18:13:26 +08:00
p . DQLMaxSearchRatePerCollection = ParamItem {
Key : "quotaAndLimits.dql.searchRate.collection.max" ,
Version : "2.2.9" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . DQLLimitEnabled . GetAsBool ( ) {
return max
}
// [0, inf)
if getAsFloat ( v ) < 0 {
2023-05-31 16:47:29 +08:00
return p . DQLMaxSearchRate . GetValue ( )
2023-05-12 18:13:26 +08:00
}
return v
} ,
Doc : "vps (vectors per second), default no limit" ,
Export : true ,
}
p . DQLMaxSearchRatePerCollection . Init ( base . mgr )
p . DQLMinSearchRatePerCollection = ParamItem {
Key : "quotaAndLimits.dql.searchRate.collection.min" ,
Version : "2.2.9" ,
DefaultValue : min ,
Formatter : func ( v string ) string {
if ! p . DQLLimitEnabled . GetAsBool ( ) {
return min
}
rate := getAsFloat ( v )
// [0, inf)
if rate < 0 {
return min
}
if ! p . checkMinMaxLegal ( rate , p . DQLMaxSearchRatePerCollection . GetAsFloat ( ) ) {
return min
}
return v
} ,
}
p . DQLMinSearchRatePerCollection . Init ( base . mgr )
2022-12-07 18:01:19 +08:00
p . DQLMaxQueryRate = ParamItem {
Key : "quotaAndLimits.dql.queryRate.max" ,
Version : "2.2.0" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . DQLLimitEnabled . GetAsBool ( ) {
return max
}
// [0, inf)
if getAsFloat ( v ) < 0 {
return max
}
return v
} ,
2023-02-23 11:37:46 +08:00
Doc : "qps, default no limit" ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . DQLMaxQueryRate . Init ( base . mgr )
p . DQLMinQueryRate = ParamItem {
Key : "quotaAndLimits.dql.queryRate.min" ,
Version : "2.2.0" ,
DefaultValue : min ,
Formatter : func ( v string ) string {
if ! p . DQLLimitEnabled . GetAsBool ( ) {
return min
}
rate := getAsFloat ( v )
// [0, inf)
if rate < 0 {
return min
}
2023-05-12 18:13:26 +08:00
if ! p . checkMinMaxLegal ( rate , p . DQLMaxQueryRate . GetAsFloat ( ) ) {
2022-12-07 18:01:19 +08:00
return min
}
return v
} ,
}
p . DQLMinQueryRate . Init ( base . mgr )
2022-09-16 09:56:47 +08:00
2023-05-12 18:13:26 +08:00
p . DQLMaxQueryRatePerCollection = ParamItem {
Key : "quotaAndLimits.dql.queryRate.collection.max" ,
Version : "2.2.9" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . DQLLimitEnabled . GetAsBool ( ) {
return max
}
// [0, inf)
if getAsFloat ( v ) < 0 {
2023-05-31 16:47:29 +08:00
return p . DQLMaxQueryRate . GetValue ( )
2023-05-12 18:13:26 +08:00
}
return v
} ,
Doc : "qps, default no limit" ,
Export : true ,
}
p . DQLMaxQueryRatePerCollection . Init ( base . mgr )
p . DQLMinQueryRatePerCollection = ParamItem {
Key : "quotaAndLimits.dql.queryRate.collection.min" ,
Version : "2.2.9" ,
DefaultValue : min ,
Formatter : func ( v string ) string {
if ! p . DQLLimitEnabled . GetAsBool ( ) {
return min
}
rate := getAsFloat ( v )
// [0, inf)
if rate < 0 {
return min
}
if ! p . checkMinMaxLegal ( rate , p . DQLMaxQueryRatePerCollection . GetAsFloat ( ) ) {
return min
}
return v
} ,
}
p . DQLMinQueryRatePerCollection . Init ( base . mgr )
2022-09-26 16:48:53 +08:00
// limits
2022-12-07 18:01:19 +08:00
p . MaxCollectionNum = ParamItem {
2023-04-28 11:02:35 +08:00
Key : "quotaAndLimits.limits.maxCollectionNum" ,
2022-12-07 18:01:19 +08:00
Version : "2.2.0" ,
2023-04-28 11:02:35 +08:00
DefaultValue : "65536" ,
2022-12-07 18:01:19 +08:00
}
p . MaxCollectionNum . Init ( base . mgr )
2022-09-16 09:56:47 +08:00
2023-04-28 11:02:35 +08:00
p . MaxCollectionNumPerDB = ParamItem {
Key : "quotaAndLimits.limits.maxCollectionNumPerDB" ,
Version : "2.2.0" ,
DefaultValue : "64" ,
}
p . MaxCollectionNumPerDB . Init ( base . mgr )
2023-06-07 10:38:36 +08:00
p . TopKLimit = ParamItem {
Key : "quotaAndLimits.limits.topK" ,
Version : "2.2.1" ,
DefaultValue : "16384" ,
FallbackKeys : [ ] string {
"common.topKLimit" ,
} ,
Doc : ` Search limit , which applies on :
maximum # of results to return ( topK ) .
Check https : //milvus.io/docs/limitations.md for more details.`,
}
p . TopKLimit . Init ( base . mgr )
p . NQLimit = ParamItem {
Key : "quotaAndLimits.limits.nq" ,
Version : "2.3.0" ,
DefaultValue : "16384" ,
FallbackKeys : [ ] string { } ,
Doc : ` Search limit , which applies on :
maximum # of search requests ( nq ) .
Check https : //milvus.io/docs/limitations.md for more details.`,
}
p . NQLimit . Init ( base . mgr )
2023-06-25 14:42:43 +08:00
p . MaxQueryResultWindow = ParamItem {
Key : "quotaAndLimits.limits.maxQueryResultWindow" ,
Version : "2.3.0" ,
DefaultValue : "16384" ,
FallbackKeys : [ ] string { } ,
Doc : ` Query limit, which applies on: maximum of offset + limit ` ,
}
p . MaxQueryResultWindow . Init ( base . mgr )
2023-08-10 14:11:15 +08:00
p . MaxOutputSize = ParamItem {
Key : "quotaAndLimits.limits.maxOutputSize" ,
Version : "2.3.0" ,
DefaultValue : "104857600" , // 100 MB, 100 * 1024 * 1024
}
p . MaxOutputSize . Init ( base . mgr )
2022-09-26 16:48:53 +08:00
// limit writing
2022-12-07 18:01:19 +08:00
p . ForceDenyWriting = ParamItem {
Key : "quotaAndLimits.limitWriting.forceDeny" ,
Version : "2.2.0" ,
DefaultValue : "false" ,
2023-02-23 11:37:46 +08:00
Doc : ` forceDeny ` + "false" + ` means dml requests are allowed ( except for some
specific conditions , such as memory of nodes to water marker ) , ` + "true" + ` means always reject all dml requests . ` ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . ForceDenyWriting . Init ( base . mgr )
p . TtProtectionEnabled = ParamItem {
Key : "quotaAndLimits.limitWriting.ttProtection.enabled" ,
Version : "2.2.0" ,
2023-02-23 11:37:46 +08:00
DefaultValue : "false" ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . TtProtectionEnabled . Init ( base . mgr )
const defaultMaxTtDelay = "300.0"
p . MaxTimeTickDelay = ParamItem {
Key : "quotaAndLimits.limitWriting.ttProtection.maxTimeTickDelay" ,
Version : "2.2.0" ,
DefaultValue : defaultMaxTtDelay ,
Formatter : func ( v string ) string {
if ! p . TtProtectionEnabled . GetAsBool ( ) {
return fmt . Sprintf ( "%d" , math . MaxInt64 )
}
delay := getAsFloat ( v )
// (0, 65536)
if delay <= 0 || delay >= 65536 {
return defaultMaxTtDelay
}
return fmt . Sprintf ( "%f" , delay )
} ,
2023-02-23 11:37:46 +08:00
Doc : ` maxTimeTickDelay indicates the backpressure for DML Operations .
DML rates would be reduced according to the ratio of time tick delay to maxTimeTickDelay ,
if time tick delay is greater than maxTimeTickDelay , all DML requests would be rejected .
seconds ` ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . MaxTimeTickDelay . Init ( base . mgr )
p . MemProtectionEnabled = ParamItem {
Key : "quotaAndLimits.limitWriting.memProtection.enabled" ,
Version : "2.2.0" ,
DefaultValue : "true" ,
2023-02-23 11:37:46 +08:00
Doc : ` When memory usage > memoryHighWaterLevel , all dml requests would be rejected ;
When memoryLowWaterLevel < memory usage < memoryHighWaterLevel , reduce the dml rate ;
When memory usage < memoryLowWaterLevel , no action . ` ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . MemProtectionEnabled . Init ( base . mgr )
lowWaterLevel := fmt . Sprintf ( "%f" , defaultLowWaterLevel )
highWaterLevel := fmt . Sprintf ( "%f" , defaultHighWaterLevel )
p . DataNodeMemoryLowWaterLevel = ParamItem {
Key : "quotaAndLimits.limitWriting.memProtection.dataNodeMemoryLowWaterLevel" ,
Version : "2.2.0" ,
DefaultValue : lowWaterLevel ,
Formatter : func ( v string ) string {
if ! p . MemProtectionEnabled . GetAsBool ( ) {
return lowWaterLevel
}
level := getAsFloat ( v )
// (0, 1]
if level <= 0 || level > 1 {
return lowWaterLevel
}
return v
} ,
2023-02-23 11:37:46 +08:00
Doc : "(0, 1], memoryLowWaterLevel in DataNodes" ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . DataNodeMemoryLowWaterLevel . Init ( base . mgr )
p . DataNodeMemoryHighWaterLevel = ParamItem {
Key : "quotaAndLimits.limitWriting.memProtection.dataNodeMemoryHighWaterLevel" ,
Version : "2.2.0" ,
DefaultValue : highWaterLevel ,
Formatter : func ( v string ) string {
if ! p . MemProtectionEnabled . GetAsBool ( ) {
return "1"
}
level := getAsFloat ( v )
// (0, 1]
if level <= 0 || level > 1 {
// log.Warn("MemoryLowWaterLevel must in the range of `(0, 1]`, use default value", zap.Float64("low", p.DataNodeMemoryHighWaterLevel), zap.Float64("default", defaultHighWaterLevel))
return highWaterLevel
}
if ! p . checkMinMaxLegal ( p . DataNodeMemoryLowWaterLevel . GetAsFloat ( ) , getAsFloat ( v ) ) {
return highWaterLevel
}
return v
} ,
2023-02-23 11:37:46 +08:00
Doc : "(0, 1], memoryHighWaterLevel in DataNodes" ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . DataNodeMemoryHighWaterLevel . Init ( base . mgr )
p . QueryNodeMemoryLowWaterLevel = ParamItem {
Key : "quotaAndLimits.limitWriting.memProtection.queryNodeMemoryLowWaterLevel" ,
Version : "2.2.0" ,
DefaultValue : lowWaterLevel ,
Formatter : func ( v string ) string {
if ! p . MemProtectionEnabled . GetAsBool ( ) {
return lowWaterLevel
}
level := getAsFloat ( v )
// (0, 1]
if level <= 0 || level > 1 {
// log.Warn("MemoryLowWaterLevel must in the range of `(0, 1]`, use default value", zap.Float64("low", p.QueryNodeMemoryLowWaterLevel), zap.Float64("default", defaultLowWaterLevel))
return lowWaterLevel
}
return v
} ,
2023-02-23 11:37:46 +08:00
Doc : "(0, 1], memoryLowWaterLevel in QueryNodes" ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . QueryNodeMemoryLowWaterLevel . Init ( base . mgr )
p . QueryNodeMemoryHighWaterLevel = ParamItem {
Key : "quotaAndLimits.limitWriting.memProtection.queryNodeMemoryHighWaterLevel" ,
Version : "2.2.0" ,
DefaultValue : highWaterLevel ,
Formatter : func ( v string ) string {
if ! p . MemProtectionEnabled . GetAsBool ( ) {
return highWaterLevel
}
level := getAsFloat ( v )
// (0, 1]
if level <= 0 || level > 1 {
// log.Warn("MemoryLowWaterLevel must in the range of `(0, 1]`, use default value", zap.Float64("low", p.QueryNodeMemoryHighWaterLevel), zap.Float64("default", defaultHighWaterLevel))
return highWaterLevel
}
if ! p . checkMinMaxLegal ( p . QueryNodeMemoryLowWaterLevel . GetAsFloat ( ) , getAsFloat ( v ) ) {
return highWaterLevel
}
return v
} ,
2023-02-23 11:37:46 +08:00
Doc : "(0, 1], memoryHighWaterLevel in QueryNodes" ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . QueryNodeMemoryHighWaterLevel . Init ( base . mgr )
2023-05-17 09:57:22 +08:00
p . GrowingSegmentsSizeProtectionEnabled = ParamItem {
Key : "quotaAndLimits.limitWriting.growingSegmentsSizeProtection.enabled" ,
Version : "2.2.9" ,
DefaultValue : "false" ,
2023-08-08 12:43:07 +08:00
Doc : ` No action will be taken if the growing segments size is less than the low watermark .
When the growing segments size exceeds the low watermark , the dml rate will be reduced ,
but the rate will not be lower than minRateRatio * dmlRate . ` ,
2023-05-17 09:57:22 +08:00
Export : true ,
}
p . GrowingSegmentsSizeProtectionEnabled . Init ( base . mgr )
2023-08-08 12:43:07 +08:00
defaultGrowingSegSizeMinRateRatio := "0.5"
p . GrowingSegmentsSizeMinRateRatio = ParamItem {
Key : "quotaAndLimits.limitWriting.growingSegmentsSizeProtection.minRateRatio" ,
Version : "2.3.0" ,
DefaultValue : defaultGrowingSegSizeMinRateRatio ,
Formatter : func ( v string ) string {
level := getAsFloat ( v )
if level <= 0 || level > 1 {
return defaultGrowingSegSizeMinRateRatio
}
return v
} ,
Export : true ,
}
p . GrowingSegmentsSizeMinRateRatio . Init ( base . mgr )
2023-05-17 09:57:22 +08:00
defaultGrowingSegSizeLowWaterLevel := "0.2"
p . GrowingSegmentsSizeLowWaterLevel = ParamItem {
Key : "quotaAndLimits.limitWriting.growingSegmentsSizeProtection.lowWaterLevel" ,
Version : "2.2.9" ,
DefaultValue : defaultGrowingSegSizeLowWaterLevel ,
Formatter : func ( v string ) string {
level := getAsFloat ( v )
if level <= 0 || level > 1 {
return defaultGrowingSegSizeLowWaterLevel
}
return v
} ,
Export : true ,
}
p . GrowingSegmentsSizeLowWaterLevel . Init ( base . mgr )
defaultGrowingSegSizeHighWaterLevel := "0.4"
p . GrowingSegmentsSizeHighWaterLevel = ParamItem {
Key : "quotaAndLimits.limitWriting.growingSegmentsSizeProtection.highWaterLevel" ,
Version : "2.2.9" ,
DefaultValue : defaultGrowingSegSizeHighWaterLevel ,
Formatter : func ( v string ) string {
level := getAsFloat ( v )
if level <= 0 || level > 1 {
return defaultGrowingSegSizeHighWaterLevel
}
if ! p . checkMinMaxLegal ( p . GrowingSegmentsSizeLowWaterLevel . GetAsFloat ( ) , getAsFloat ( v ) ) {
return defaultGrowingSegSizeHighWaterLevel
}
return v
} ,
Export : true ,
}
p . GrowingSegmentsSizeHighWaterLevel . Init ( base . mgr )
2022-12-07 18:01:19 +08:00
p . DiskProtectionEnabled = ParamItem {
Key : "quotaAndLimits.limitWriting.diskProtection.enabled" ,
Version : "2.2.0" ,
DefaultValue : "true" ,
2023-02-23 11:37:46 +08:00
Doc : "When the total file size of object storage is greater than `diskQuota`, all dml requests would be rejected;" ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . DiskProtectionEnabled . Init ( base . mgr )
quota := fmt . Sprintf ( "%f" , defaultDiskQuotaInMB )
p . DiskQuota = ParamItem {
Key : "quotaAndLimits.limitWriting.diskProtection.diskQuota" ,
Version : "2.2.0" ,
DefaultValue : quota ,
Formatter : func ( v string ) string {
if ! p . DiskProtectionEnabled . GetAsBool ( ) {
return max
}
level := getAsFloat ( v )
// (0, +inf)
if level <= 0 {
2023-05-31 16:47:29 +08:00
return max
2022-12-07 18:01:19 +08:00
}
// megabytes to bytes
return fmt . Sprintf ( "%f" , megaBytes2Bytes ( level ) )
} ,
2023-02-23 11:37:46 +08:00
Doc : "MB, (0, +inf), default no limit" ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . DiskQuota . Init ( base . mgr )
2022-09-16 09:56:47 +08:00
2023-04-26 21:52:36 +08:00
p . DiskQuotaPerCollection = ParamItem {
Key : "quotaAndLimits.limitWriting.diskProtection.diskQuotaPerCollection" ,
Version : "2.2.8" ,
DefaultValue : quota ,
Formatter : func ( v string ) string {
if ! p . DiskProtectionEnabled . GetAsBool ( ) {
return max
}
level := getAsFloat ( v )
// (0, +inf)
if level <= 0 {
2023-05-31 16:47:29 +08:00
return p . DiskQuota . GetValue ( )
2023-04-26 21:52:36 +08:00
}
// megabytes to bytes
return fmt . Sprintf ( "%f" , megaBytes2Bytes ( level ) )
} ,
Doc : "MB, (0, +inf), default no limit" ,
Export : true ,
}
p . DiskQuotaPerCollection . Init ( base . mgr )
2022-09-26 16:48:53 +08:00
// limit reading
2022-12-07 18:01:19 +08:00
p . ForceDenyReading = ParamItem {
Key : "quotaAndLimits.limitReading.forceDeny" ,
Version : "2.2.0" ,
DefaultValue : "false" ,
2023-02-23 11:37:46 +08:00
Doc : ` forceDeny ` + "false" + ` means dql requests are allowed ( except for some
specific conditions , such as collection has been dropped ) , ` + "true" + ` means always reject all dql requests . ` ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . ForceDenyReading . Init ( base . mgr )
p . QueueProtectionEnabled = ParamItem {
Key : "quotaAndLimits.limitReading.queueProtection.enabled" ,
Version : "2.2.0" ,
DefaultValue : "false" ,
2023-02-23 11:37:46 +08:00
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . QueueProtectionEnabled . Init ( base . mgr )
p . NQInQueueThreshold = ParamItem {
Key : "quotaAndLimits.limitReading.queueProtection.nqInQueueThreshold" ,
Version : "2.2.0" ,
DefaultValue : strconv . FormatInt ( math . MaxInt64 , 10 ) ,
Formatter : func ( v string ) string {
if ! p . QueueProtectionEnabled . GetAsBool ( ) {
return strconv . FormatInt ( math . MaxInt64 , 10 )
}
threshold := getAsFloat ( v )
// [0, inf)
if threshold < 0 {
return strconv . FormatInt ( math . MaxInt64 , 10 )
}
return v
} ,
2023-02-23 11:37:46 +08:00
Doc : ` nqInQueueThreshold indicated that the system was under backpressure for Search / Query path .
If NQ in any QueryNode ' s queue is greater than nqInQueueThreshold , search & query rates would gradually cool off
until the NQ in queue no longer exceeds nqInQueueThreshold . We think of the NQ of query request as 1.
int , default no limit ` ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . NQInQueueThreshold . Init ( base . mgr )
p . QueueLatencyThreshold = ParamItem {
Key : "quotaAndLimits.limitReading.queueProtection.queueLatencyThreshold" ,
Version : "2.2.0" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . QueueProtectionEnabled . GetAsBool ( ) {
return max
}
level := getAsFloat ( v )
// [0, inf)
if level < 0 {
return max
}
return v
} ,
2023-02-23 11:37:46 +08:00
Doc : ` queueLatencyThreshold indicated that the system was under backpressure for Search / Query path .
If dql latency of queuing is greater than queueLatencyThreshold , search & query rates would gradually cool off
until the latency of queuing no longer exceeds queueLatencyThreshold .
The latency here refers to the averaged latency over a period of time .
milliseconds , default no limit ` ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . QueueLatencyThreshold . Init ( base . mgr )
p . ResultProtectionEnabled = ParamItem {
Key : "quotaAndLimits.limitReading.resultProtection.enabled" ,
Version : "2.2.0" ,
DefaultValue : "false" ,
2023-02-23 11:37:46 +08:00
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . ResultProtectionEnabled . Init ( base . mgr )
p . MaxReadResultRate = ParamItem {
Key : "quotaAndLimits.limitReading.resultProtection.maxReadResultRate" ,
Version : "2.2.0" ,
DefaultValue : max ,
Formatter : func ( v string ) string {
if ! p . ResultProtectionEnabled . GetAsBool ( ) {
return max
}
rate := getAsFloat ( v )
if math . Abs ( rate - defaultMax ) > 0.001 { // maxRate != defaultMax
return fmt . Sprintf ( "%f" , megaBytes2Bytes ( rate ) )
}
// [0, inf)
if rate < 0 {
return max
}
return v
} ,
2023-02-23 11:37:46 +08:00
Doc : ` maxReadResultRate indicated that the system was under backpressure for Search / Query path .
If dql result rate is greater than maxReadResultRate , search & query rates would gradually cool off
until the read result rate no longer exceeds maxReadResultRate .
MB / s , default no limit ` ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . MaxReadResultRate . Init ( base . mgr )
const defaultSpeed = "0.9"
p . CoolOffSpeed = ParamItem {
Key : "quotaAndLimits.limitReading.coolOffSpeed" ,
Version : "2.2.0" ,
DefaultValue : defaultSpeed ,
Formatter : func ( v string ) string {
// (0, 1]
speed := getAsFloat ( v )
if speed <= 0 || speed > 1 {
// log.Warn("CoolOffSpeed must in the range of `(0, 1]`, use default value", zap.Float64("speed", p.CoolOffSpeed), zap.Float64("default", defaultSpeed))
return defaultSpeed
}
return v
} ,
2023-02-23 11:37:46 +08:00
Doc : ` colOffSpeed is the speed of search & query rates cool off .
( 0 , 1 ] ` ,
Export : true ,
2022-12-07 18:01:19 +08:00
}
p . CoolOffSpeed . Init ( base . mgr )
2022-09-16 09:56:47 +08:00
}
2022-10-17 16:23:25 +08:00
func megaBytes2Bytes ( f float64 ) float64 {
return f * MBSize
2022-09-16 09:56:47 +08:00
}
func ( p * quotaConfig ) checkMinMaxLegal ( min , max float64 ) bool {
if min > max {
log . Warn ( "init QuotaConfig failed, max/high must be greater than or equal to min/low, use default values" ,
2022-10-27 17:37:32 +08:00
zap . String ( "msg" , fmt . Sprintf ( "min: %v, max: %v, defaultMin: %v, defaultMax: %v" , min , max , defaultMin , defaultMax ) ) )
2022-09-16 09:56:47 +08:00
return false
}
return true
}