Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate query limits for store gateway #5579

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/configuration/config-file-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3022,6 +3022,16 @@ The `limits_config` configures default and per-tenant limits imposed by Cortex s
# CLI flag: -store-gateway.max-downloaded-bytes-per-request
[max_downloaded_bytes_per_request: <int> | default = 0]

# The maximum number of series to fetch per gRPC request in Store Gateway,
# including Series/LabelNames/LabelValues requests. 0 to disable.
# CLI flag: -store-gateway.max-series-per-request
[max_series_per_request: <int> | default = 0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These limits are not deterministic? Doesn't it depend on how the blocks where sharded on store-gateways? Could we implement this per block?


# The maximum number of chunks to fetch per gRPC request in Store Gateway for
# Series requests. 0 to disable.
# CLI flag: -store-gateway.max-chunks-per-request
[max_chunks_per_request: <int> | default = 0]

# Delete blocks containing samples older than the specified retention period. 0
# to disable.
# CLI flag: -compactor.blocks-retention-period
Expand Down
4 changes: 2 additions & 2 deletions pkg/storegateway/bucket_stores.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ func newChunksLimiterFactory(limits *validation.Overrides, userID string) store.
// Since limit overrides could be live reloaded, we have to get the current user's limit
// each time a new limiter is instantiated.
return &limiter{
limiter: store.NewLimiter(uint64(limits.MaxChunksPerQueryFromStore(userID)), failedCounter),
limiter: store.NewLimiter(uint64(limits.MaxChunksPerRequest(userID)), failedCounter),
}
}
}
Expand All @@ -740,7 +740,7 @@ func newSeriesLimiterFactory(limits *validation.Overrides, userID string) store.
// Since limit overrides could be live reloaded, we have to get the current user's limit
// each time a new limiter is instantiated.
return &limiter{
limiter: store.NewLimiter(uint64(limits.MaxFetchedSeriesPerQuery(userID)), failedCounter),
limiter: store.NewLimiter(uint64(limits.MaxSeriesPerRequest(userID)), failedCounter),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/storegateway/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ func TestStoreGateway_SeriesQueryingShouldEnforceMaxChunksPerQueryLimit(t *testi
//parallel testing causes data race
// Customise the limits.
limits := defaultLimitsConfig()
limits.MaxChunksPerQuery = testData.limit
limits.MaxChunksPerRequest = testData.limit
overrides, err := validation.NewOverrides(limits, nil)
require.NoError(t, err)

Expand Down Expand Up @@ -1130,7 +1130,7 @@ func TestStoreGateway_SeriesQueryingShouldEnforceMaxSeriesPerQueryLimit(t *testi
//parallel testing causes data race
// Customise the limits.
limits := defaultLimitsConfig()
limits.MaxFetchedSeriesPerQuery = testData.limit
limits.MaxSeriesPerRequest = testData.limit
overrides, err := validation.NewOverrides(limits, nil)
require.NoError(t, err)

Expand Down
16 changes: 16 additions & 0 deletions pkg/util/validation/limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ type Limits struct {
// Store-gateway.
StoreGatewayTenantShardSize float64 `yaml:"store_gateway_tenant_shard_size" json:"store_gateway_tenant_shard_size"`
MaxDownloadedBytesPerRequest int `yaml:"max_downloaded_bytes_per_request" json:"max_downloaded_bytes_per_request"`
MaxSeriesPerRequest int `yaml:"max_series_per_request" json:"max_series_per_request"`
MaxChunksPerRequest int `yaml:"max_chunks_per_request" json:"max_chunks_per_request"`

// Compactor.
CompactorBlocksRetentionPeriod model.Duration `yaml:"compactor_blocks_retention_period" json:"compactor_blocks_retention_period"`
Expand Down Expand Up @@ -200,6 +202,8 @@ func (l *Limits) RegisterFlags(f *flag.FlagSet) {
// Store-gateway.
f.Float64Var(&l.StoreGatewayTenantShardSize, "store-gateway.tenant-shard-size", 0, "The default tenant's shard size when the shuffle-sharding strategy is used. Must be set when the store-gateway sharding is enabled with the shuffle-sharding strategy. When this setting is specified in the per-tenant overrides, a value of 0 disables shuffle sharding for the tenant. If the value is < 1 the shard size will be a percentage of the total store-gateways.")
f.IntVar(&l.MaxDownloadedBytesPerRequest, "store-gateway.max-downloaded-bytes-per-request", 0, "The maximum number of data bytes to download per gRPC request in Store Gateway, including Series/LabelNames/LabelValues requests. 0 to disable.")
f.IntVar(&l.MaxSeriesPerRequest, "store-gateway.max-series-per-request", 0, "The maximum number of series to fetch per gRPC request in Store Gateway, including Series/LabelNames/LabelValues requests. 0 to disable.")
f.IntVar(&l.MaxChunksPerRequest, "store-gateway.max-chunks-per-request", 0, "The maximum number of chunks to fetch per gRPC request in Store Gateway for Series requests. 0 to disable.")

// Alertmanager.
f.Var(&l.AlertmanagerReceiversBlockCIDRNetworks, "alertmanager.receivers-firewall-block-cidr-networks", "Comma-separated list of network CIDRs to block in Alertmanager receiver integrations.")
Expand Down Expand Up @@ -454,6 +458,18 @@ func (o *Overrides) MaxDownloadedBytesPerRequest(userID string) int {
return o.GetOverridesForUser(userID).MaxDownloadedBytesPerRequest
}

// MaxSeriesPerRequest returns the maximum number of series to download for each gRPC request in Store Gateway,
// including any series fetched from cache or object storage.
func (o *Overrides) MaxSeriesPerRequest(userID string) int {
return o.GetOverridesForUser(userID).MaxSeriesPerRequest
}

// MaxChunksPerRequest returns the maximum number of chunks to download for each gRPC request in Store Gateway,
// including any chunks fetched from cache or object storage.
func (o *Overrides) MaxChunksPerRequest(userID string) int {
return o.GetOverridesForUser(userID).MaxChunksPerRequest
}

// MaxQueryLookback returns the max lookback period of queries.
func (o *Overrides) MaxQueryLookback(userID string) time.Duration {
return time.Duration(o.GetOverridesForUser(userID).MaxQueryLookback)
Expand Down
Loading