github.com/m3db/m3@v1.5.1-0.20231129193456-75a402aa583b/src/cmd/services/m3dbnode/config/limits.go (about) 1 // Copyright (c) 2019 Uber Technologies, Inc. 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 // 10 // The above copyright notice and this permission notice shall be included in 11 // all copies or substantial portions of the Software. 12 // 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 // THE SOFTWARE. 20 21 package config 22 23 import "time" 24 25 // LimitsConfiguration contains configuration for configurable limits that can be applied to M3DB. 26 type LimitsConfiguration struct { 27 // MaxRecentlyQueriedSeriesDiskBytesRead sets the upper limit on time series bytes 28 // read from disk within a given lookback period. Queries which are issued while this 29 // max is surpassed encounter an error. 30 MaxRecentlyQueriedSeriesDiskBytesRead *MaxRecentQueryResourceLimitConfiguration `yaml:"maxRecentlyQueriedSeriesDiskBytesRead"` 31 32 // MaxRecentlyQueriedSeriesDiskRead sets the upper limit on time series read from disk within a given lookback 33 // period. Queries which are issued while this max is surpassed encounter an error. 34 // This is the number of time series, which is different from the number of bytes controlled by 35 // MaxRecentlyQueriedSeriesDiskBytesRead. 36 MaxRecentlyQueriedSeriesDiskRead *MaxRecentQueryResourceLimitConfiguration `yaml:"maxRecentlyQueriedSeriesDiskRead"` 37 38 // MaxRecentlyQueriedSeriesBlocks sets the upper limit on time series blocks 39 // count within a given lookback period. Queries which are issued while this 40 // max is surpassed encounter an error. 41 MaxRecentlyQueriedSeriesBlocks *MaxRecentQueryResourceLimitConfiguration `yaml:"maxRecentlyQueriedSeriesBlocks"` 42 43 // MaxRecentlyQueriedMetadata sets the upper limit on metadata counts 44 // within a given lookback period. Metadata queries which are issued while 45 // this max is surpassed encounter an error. 46 MaxRecentlyQueriedMetadata *MaxRecentQueryResourceLimitConfiguration `yaml:"maxRecentlyQueriedMetadata"` 47 48 // MaxOutstandingWriteRequests controls the maximum number of outstanding write requests 49 // that the server will allow before it begins rejecting requests. Note that this value 50 // is independent of the number of values that are being written (due to variable batch 51 // size from the client) but is still very useful for enforcing backpressure due to the fact 52 // that all writes within a single RPC are single-threaded. 53 MaxOutstandingWriteRequests int `yaml:"maxOutstandingWriteRequests" validate:"min=0"` 54 55 // MaxOutstandingReadRequests controls the maximum number of outstanding read requests that 56 // the server will allow before it begins rejecting requests. Just like MaxOutstandingWriteRequests 57 // this value is independent of the number of time series being read. 58 MaxOutstandingReadRequests int `yaml:"maxOutstandingReadRequests" validate:"min=0"` 59 60 // MaxOutstandingRepairedBytes controls the maximum number of bytes that can be loaded into memory 61 // as part of the repair process. For example if the value was set to 2^31 then up to 2GiB of 62 // repaired data could be "outstanding" in memory at one time. Once that limit was hit, the repair 63 // process would pause until some of the repaired bytes had been persisted to disk (and subsequently 64 // evicted from memory) at which point it would resume. 65 MaxOutstandingRepairedBytes int64 `yaml:"maxOutstandingRepairedBytes" validate:"min=0"` 66 67 // MaxEncodersPerBlock is the maximum number of encoders permitted in a block. 68 // When there are too many encoders, merging them (during a tick) puts a high 69 // load on the CPU, which can prevent other DB operations. 70 // A setting of 0 means there is no maximum. 71 MaxEncodersPerBlock int `yaml:"maxEncodersPerBlock" validate:"min=0"` 72 73 // Write new series limit per second to limit overwhelming during new ID bursts. 74 WriteNewSeriesPerSecond int `yaml:"writeNewSeriesPerSecond" validate:"min=0"` 75 } 76 77 // MaxRecentQueryResourceLimitConfiguration sets an upper limit on resources consumed by all queries 78 // globally within a dbnode per some lookback period of time. Once exceeded, queries within that period 79 // of time will be abandoned. 80 type MaxRecentQueryResourceLimitConfiguration struct { 81 // Value sets the max value for the resource limit. 82 Value int64 `yaml:"value" validate:"min=0"` 83 // Lookback is the period in which a given resource limit is enforced. 84 Lookback time.Duration `yaml:"lookback" validate:"min=0"` 85 }