Skip to content

Commit 91ff8b4

Browse files
authored
Add hedged request to Store Gateway (#6388)
Signed-off-by: SungJin1212 <[email protected]>
1 parent 8751c97 commit 91ff8b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2165
-28
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* [FEATURE] Chunk Cache: Support multi level cache and add metrics. #6249
1818
* [FEATURE] Distributor: Accept multiple HA Tracker pairs in the same request. #6256
1919
* [FEATURE] Ruler: Add support for per-user external labels #6340
20+
* [ENHANCEMENT] Store Gateway: Add a hedged request to reduce the tail latency. #6388
2021
* [ENHANCEMENT] Ingester: Add metrics to track succeed/failed native histograms. #6370
2122
* [ENHANCEMENT] Query Frontend/Querier: Add an experimental flag `-querier.enable-promql-experimental-functions` to enable experimental promQL functions. #6355
2223
* [ENHANCEMENT] OTLP: Add `-distributor.otlp-max-recv-msg-size` flag to limit OTLP request size in bytes. #6333

docs/blocks-storage/store-gateway.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,23 @@ store_gateway:
344344
# tenant(s) for processing will ignore them instead.
345345
# CLI flag: -store-gateway.disabled-tenants
346346
[disabled_tenants: <string> | default = ""]
347+
348+
hedged_request:
349+
# If true, hedged requests are applied to object store calls. It can help
350+
# with reducing tail latency.
351+
# CLI flag: -store-gateway.hedged-request.enabled
352+
[enabled: <boolean> | default = false]
353+
354+
# Maximum number of hedged requests allowed for each initial request. A high
355+
# number can reduce latency but increase internal calls.
356+
# CLI flag: -store-gateway.hedged-request.max-requests
357+
[max_requests: <int> | default = 3]
358+
359+
# It is used to calculate a latency threshold to trigger hedged requests.
360+
# For example, additional requests are triggered when the initial request
361+
# response time exceeds the 90th percentile.
362+
# CLI flag: -store-gateway.hedged-request.quantile
363+
[quantile: <float> | default = 0.9]
347364
```
348365
349366
### `blocks_storage_config`

docs/configuration/config-file-reference.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5664,6 +5664,23 @@ sharding_ring:
56645664
# tenant(s) for processing will ignore them instead.
56655665
# CLI flag: -store-gateway.disabled-tenants
56665666
[disabled_tenants: <string> | default = ""]
5667+
5668+
hedged_request:
5669+
# If true, hedged requests are applied to object store calls. It can help with
5670+
# reducing tail latency.
5671+
# CLI flag: -store-gateway.hedged-request.enabled
5672+
[enabled: <boolean> | default = false]
5673+
5674+
# Maximum number of hedged requests allowed for each initial request. A high
5675+
# number can reduce latency but increase internal calls.
5676+
# CLI flag: -store-gateway.hedged-request.max-requests
5677+
[max_requests: <int> | default = 3]
5678+
5679+
# It is used to calculate a latency threshold to trigger hedged requests. For
5680+
# example, additional requests are triggered when the initial request response
5681+
# time exceeds the 90th percentile.
5682+
# CLI flag: -store-gateway.hedged-request.quantile
5683+
[quantile: <float> | default = 0.9]
56675684
```
56685685

56695686
### `tracing_config`

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,11 @@ require (
116116
github.com/benbjohnson/clock v1.3.5 // indirect
117117
github.com/beorn7/perks v1.0.1 // indirect
118118
github.com/blang/semver/v4 v4.0.0 // indirect
119+
github.com/caio/go-tdigest v3.1.0+incompatible // indirect
119120
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
120121
github.com/coreos/go-semver v0.3.0 // indirect
121122
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
123+
github.com/cristalhq/hedgedhttp v0.9.1 // indirect
122124
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
123125
github.com/dennwc/varint v1.0.0 // indirect
124126
github.com/dgryski/go-metro v0.0.0-20200812162917-85c65e2d0165 // indirect

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,8 @@ github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl
897897
github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
898898
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874 h1:N7oVaKyGp8bttX0bfZGmcGkjz7DLQXhAn3DNd3T0ous=
899899
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874/go.mod h1:r5xuitiExdLAJ09PR7vBVENGvp4ZuTBeWTGtxuX3K+c=
900+
github.com/caio/go-tdigest v3.1.0+incompatible h1:uoVMJ3Q5lXmVLCCqaMGHLBWnbGoN6Lpu7OAUPR60cds=
901+
github.com/caio/go-tdigest v3.1.0+incompatible/go.mod h1:sHQM/ubZStBUmF1WbB8FAm8q9GjDajLC5T7ydxE3JHI=
900902
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
901903
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
902904
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
@@ -942,6 +944,8 @@ github.com/cortexproject/promqlsmith v0.0.0-20241121054008-8b48fe2471ef/go.mod h
942944
github.com/cortexproject/weaveworks-common v0.0.0-20241129212437-96019edf21f1 h1:UoSixdl0sBUhfEOMpIGxFnJjp3/y/+nkw6Du7su05FE=
943945
github.com/cortexproject/weaveworks-common v0.0.0-20241129212437-96019edf21f1/go.mod h1:7cl8fS/nivXe2DmBUUmr/3UGTJG2jVU2NRaIayR2Zjs=
944946
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
947+
github.com/cristalhq/hedgedhttp v0.9.1 h1:g68L9cf8uUyQKQJwciD0A1Vgbsz+QgCjuB1I8FAsCDs=
948+
github.com/cristalhq/hedgedhttp v0.9.1/go.mod h1:XkqWU6qVMutbhW68NnzjWrGtH8NUx1UfYqGYtHVKIsI=
945949
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
946950
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
947951
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
@@ -1390,6 +1394,8 @@ github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6Fm
13901394
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
13911395
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
13921396
github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80/go.mod h1:imJHygn/1yfhB7XSJJKlFZKl/J+dCPAknuiaGOshXAs=
1397+
github.com/leesper/go_rng v0.0.0-20190531154944-a612b043e353 h1:X/79QL0b4YJVO5+OsPH9rF2u428CIrGL/jLmPsoOQQ4=
1398+
github.com/leesper/go_rng v0.0.0-20190531154944-a612b043e353/go.mod h1:N0SVk0uhy+E1PZ3C9ctsPRlvOPAFPkCNlcPBDkt0N3U=
13931399
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
13941400
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
13951401
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=

integration/e2ecortex/storage.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type S3Client struct {
2121
}
2222

2323
func NewS3Client(cfg s3.Config) (*S3Client, error) {
24-
writer, err := s3.NewBucketClient(cfg, "test", log.NewNopLogger())
24+
writer, err := s3.NewBucketClient(cfg, nil, "test", log.NewNopLogger())
2525
if err != nil {
2626
return nil, err
2727
}

pkg/alertmanager/alertstore/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func NewAlertStore(ctx context.Context, cfg Config, cfgProvider bucket.TenantCon
6262
return local.NewStore(cfg.Local)
6363
}
6464

65-
bucketClient, err := bucket.NewClient(ctx, cfg.Config, "alertmanager-storage", logger, reg)
65+
bucketClient, err := bucket.NewClient(ctx, cfg.Config, nil, "alertmanager-storage", logger, reg)
6666
if err != nil {
6767
return nil, err
6868
}

pkg/compactor/compactor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ type Compactor struct {
384384
// NewCompactor makes a new Compactor.
385385
func NewCompactor(compactorCfg Config, storageCfg cortex_tsdb.BlocksStorageConfig, logger log.Logger, registerer prometheus.Registerer, limits *validation.Overrides) (*Compactor, error) {
386386
bucketClientFactory := func(ctx context.Context) (objstore.InstrumentedBucket, error) {
387-
return bucket.NewClient(ctx, storageCfg.Bucket, "compactor", logger, registerer)
387+
return bucket.NewClient(ctx, storageCfg.Bucket, nil, "compactor", logger, registerer)
388388
}
389389

390390
blocksGrouperFactory := compactorCfg.BlocksGrouperFactory

pkg/cortex/modules.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (t *Cortex) initRuntimeConfig() (services.Service, error) {
177177
}
178178
}
179179
}
180-
return bucket.NewClient(ctx, t.Cfg.RuntimeConfig.StorageConfig, "runtime-config", logger, registerer)
180+
return bucket.NewClient(ctx, t.Cfg.RuntimeConfig.StorageConfig, nil, "runtime-config", logger, registerer)
181181
}
182182
serv, err := runtimeconfig.New(t.Cfg.RuntimeConfig, registerer, logger, bucketClientFactory)
183183
if err == nil {

pkg/ingester/ingester.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ func New(cfg Config, limits *validation.Overrides, registerer prometheus.Registe
693693
cfg.ingesterClientFactory = client.MakeIngesterClient
694694
}
695695

696-
bucketClient, err := bucket.NewClient(context.Background(), cfg.BlocksStorageConfig.Bucket, "ingester", logger, registerer)
696+
bucketClient, err := bucket.NewClient(context.Background(), cfg.BlocksStorageConfig.Bucket, nil, "ingester", logger, registerer)
697697
if err != nil {
698698
return nil, errors.Wrap(err, "failed to create the bucket client")
699699
}
@@ -769,7 +769,7 @@ func New(cfg Config, limits *validation.Overrides, registerer prometheus.Registe
769769
// this is a special version of ingester used by Flusher. This ingester is not ingesting anything, its only purpose is to react
770770
// on Flush method and flush all opened TSDBs when called.
771771
func NewForFlusher(cfg Config, limits *validation.Overrides, registerer prometheus.Registerer, logger log.Logger) (*Ingester, error) {
772-
bucketClient, err := bucket.NewClient(context.Background(), cfg.BlocksStorageConfig.Bucket, "ingester", logger, registerer)
772+
bucketClient, err := bucket.NewClient(context.Background(), cfg.BlocksStorageConfig.Bucket, nil, "ingester", logger, registerer)
773773
if err != nil {
774774
return nil, errors.Wrap(err, "failed to create the bucket client")
775775
}

0 commit comments

Comments
 (0)