vitess.io/vitess@v0.16.2/proto/throttlerdata.proto (about) 1 /* 2 Copyright 2019 The Vitess Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 // Data structures for the throttler RPC interface. 18 19 syntax = "proto3"; 20 option go_package = "vitess.io/vitess/go/vt/proto/throttlerdata"; 21 22 package throttlerdata; 23 24 // MaxRatesRequest is the payload for the MaxRates RPC. 25 message MaxRatesRequest { 26 } 27 28 // MaxRatesResponse is returned by the MaxRates RPC. 29 message MaxRatesResponse { 30 // max_rates returns the max rate for each throttler. It's keyed by the 31 // throttler name. 32 map<string, int64> rates = 1; 33 } 34 35 // SetMaxRateRequest is the payload for the SetMaxRate RPC. 36 message SetMaxRateRequest { 37 int64 rate = 1; 38 } 39 40 // SetMaxRateResponse is returned by the SetMaxRate RPC. 41 message SetMaxRateResponse { 42 // names is the list of throttler names which were updated. 43 repeated string names = 1; 44 } 45 46 // Configuration holds the configuration parameters for the 47 // MaxReplicationLagModule which adaptively adjusts the throttling rate based on 48 // the observed replication lag across all replicas. 49 message Configuration { 50 // target_replication_lag_sec is the replication lag (in seconds) the 51 // MaxReplicationLagModule tries to aim for. 52 // If it is within the target, it tries to increase the throttler 53 // rate, otherwise it will lower it based on an educated guess of the 54 // replica's throughput. 55 int64 target_replication_lag_sec = 1; 56 57 // max_replication_lag_sec is meant as a last resort. 58 // By default, the module tries to find out the system maximum capacity while 59 // trying to keep the replication lag around "target_replication_lag_sec". 60 // Usually, we'll wait min_duration_between_(increases|decreases)_sec to see 61 // the effect of a throttler rate change on the replication lag. 62 // But if the lag goes above this field's value we will go into an "emergency" 63 // state and throttle more aggressively (see "emergency_decrease" below). 64 // This is the only way to ensure that the system will recover. 65 int64 max_replication_lag_sec = 2; 66 67 // initial_rate is the rate at which the module will start. 68 int64 initial_rate = 3; 69 70 // max_increase defines by how much we will increase the rate 71 // e.g. 0.05 increases the rate by 5% while 1.0 by 100%. 72 // Note that any increase will let the system wait for at least 73 // (1 / MaxIncrease) seconds. If we wait for shorter periods of time, we 74 // won't notice if the rate increase also increases the replication lag. 75 // (If the system was already at its maximum capacity (e.g. 1k QPS) and we 76 // increase the rate by e.g. 5% to 1050 QPS, it will take 20 seconds until 77 // 1000 extra queries are buffered and the lag increases by 1 second.) 78 double max_increase = 4; 79 80 // emergency_decrease defines by how much we will decrease the current rate 81 // if the observed replication lag is above "max_replication_lag_sec". 82 // E.g. 0.50 decreases the current rate by 50%. 83 double emergency_decrease = 5; 84 85 // min_duration_between_increases_sec specifies how long we'll wait at least 86 // for the last rate increase to have an effect on the system. 87 int64 min_duration_between_increases_sec = 6; 88 89 // max_duration_between_increases_sec specifies how long we'll wait at most 90 // for the last rate increase to have an effect on the system. 91 int64 max_duration_between_increases_sec = 7; 92 93 // min_duration_between_decreases_sec specifies how long we'll wait at least 94 // for the last rate decrease to have an effect on the system. 95 int64 min_duration_between_decreases_sec = 8; 96 97 // spread_backlog_across_sec is used when we set the throttler rate after 98 // we guessed the rate of a replica and determined its backlog. 99 // For example, at a guessed rate of 100 QPS and a lag of 10s, the replica has 100 // a backlog of 1000 queries. 101 // When we set the new, decreased throttler rate, we factor in how long it 102 // will take the replica to go through the backlog (in addition to new 103 // requests). This field specifies over which timespan we plan to spread this. 104 // For example, for a backlog of 1000 queries spread over 5s means that we 105 // have to further reduce the rate by 200 QPS or the backlog will not be 106 // processed within the 5 seconds. 107 int64 spread_backlog_across_sec = 9; 108 109 // ignore_n_slowest_replicas will ignore replication lag updates from the 110 // N slowest REPLICA tablets. Under certain circumstances, replicas are still 111 // considered e.g. a) if the lag is at most max_replication_lag_sec, b) there 112 // are less than N+1 replicas or c) the lag increased on each replica such 113 // that all replicas were ignored in a row. 114 int32 ignore_n_slowest_replicas = 10; 115 116 // ignore_n_slowest_rdonlys does the same thing as ignore_n_slowest_replicas 117 // but for RDONLY tablets. Note that these two settings are independent. 118 int32 ignore_n_slowest_rdonlys = 11; 119 120 // age_bad_rate_after_sec is the duration after which an unchanged bad rate 121 // will "age out" and increase by "bad_rate_increase". 122 // Bad rates are tracked by the code in memory.go and serve as an upper bound 123 // for future rate changes. This ensures that the adaptive throttler does not 124 // try known too high (bad) rates over and over again. 125 // To avoid that temporary degradations permanently reduce the maximum rate, 126 // a stable bad rate "ages out" after "age_bad_rate_after_sec". 127 int64 age_bad_rate_after_sec = 12; 128 129 // bad_rate_increase defines the percentage by which a bad rate will be 130 // increased when it's aging out. 131 double bad_rate_increase = 13; 132 133 // max_rate_approach_threshold is the fraction of the current rate limit that the actual 134 // rate must exceed for the throttler to increase the limit when the replication lag 135 // is below target_replication_lag_sec. For example, assuming the actual replication lag 136 // is below target_replication_lag_sec, if the current rate limit is 100, then the actual 137 // rate must exceed 100*max_rate_approach_threshold for the throttler to increase the current 138 // limit. 139 double max_rate_approach_threshold = 14; 140 } 141 142 // GetConfigurationRequest is the payload for the GetConfiguration RPC. 143 message GetConfigurationRequest { 144 // throttler_name specifies which throttler to select. If empty, all active 145 // throttlers will be selected. 146 string throttler_name = 1; 147 } 148 149 // GetConfigurationResponse is returned by the GetConfiguration RPC. 150 message GetConfigurationResponse { 151 // max_rates returns the configurations for each throttler. 152 // It's keyed by the throttler name. 153 map<string, Configuration> configurations = 1; 154 } 155 156 // UpdateConfigurationRequest is the payload for the UpdateConfiguration RPC. 157 message UpdateConfigurationRequest { 158 // throttler_name specifies which throttler to update. If empty, all active 159 // throttlers will be updated. 160 string throttler_name = 1; 161 // configuration is the new (partial) configuration. 162 Configuration configuration = 2; 163 // copy_zero_values specifies whether fields with zero values should be copied 164 // as well. 165 bool copy_zero_values = 3; 166 } 167 168 // UpdateConfigurationResponse is returned by the UpdateConfiguration RPC. 169 message UpdateConfigurationResponse { 170 // names is the list of throttler names which were updated. 171 repeated string names = 1; 172 } 173 174 // ResetConfigurationRequest is the payload for the ResetConfiguration RPC. 175 message ResetConfigurationRequest { 176 // throttler_name specifies which throttler to reset. If empty, all active 177 // throttlers will be reset. 178 string throttler_name = 1; 179 } 180 181 // ResetConfigurationResponse is returned by the ResetConfiguration RPC. 182 message ResetConfigurationResponse { 183 // names is the list of throttler names which were updated. 184 repeated string names = 1; 185 }