Skip to content

Commit f81ab51

Browse files
authored
refactor: rework the proxy engine cache read/write to add concurrency limits (#900)
Signed-off-by: Chris Randles <randles.chris@gmail.com>
1 parent 75d6efc commit f81ab51

File tree

11 files changed

+592
-219
lines changed

11 files changed

+592
-219
lines changed

pkg/backends/options/defaults.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ const (
6565
DefaultTimeseriesShardSize = 0
6666
// DefaultTimeseriesShardStep defines the default shard step of 0 (no sharding)
6767
DefaultTimeseriesShardStep = 0
68+
// DefaultChunkReadConcurrencyLimit defines the default chunk read concurrency limit
69+
DefaultChunkReadConcurrencyLimit = 16
70+
// DefaultChunkReadConcurrencyLimit defines the default chunk write concurrency limit
71+
DefaultChunkWriteConcurrencyLimit = 16
6872
)
6973

7074
// DefaultCompressibleTypes returns a list of types that Trickster should compress before caching

pkg/backends/options/options.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ type Options struct {
7575
CacheName string `yaml:"cache_name,omitempty"`
7676
// CacheKeyPrefix defines the cache key prefix the backend will use when writing objects to the cache
7777
CacheKeyPrefix string `yaml:"cache_key_prefix,omitempty"`
78+
// ChunkReadConcurrencyLimit defines the concurrency limit while reading a chunked object
79+
ChunkReadConcurrencyLimit int `yaml:"chunk_read_concurrency_limit,omitempty"`
80+
// ChunkWriteConcurrencyLimit defines the concurrency limit while writing a chunked object
81+
ChunkWriteConcurrencyLimit int `yaml:"chunk_write_concurrency_limit,omitempty"`
7882
// HealthCheck is the health check options reference for this backend
7983
HealthCheck *ho.Options `yaml:"healthcheck,omitempty"`
8084
// Object Proxy Cache and Delta Proxy Cache Configurations
@@ -226,6 +230,8 @@ func New() *Options {
226230
CacheKeyPrefix: "",
227231
CacheName: DefaultBackendCacheName,
228232
CompressibleTypeList: DefaultCompressibleTypes(),
233+
ChunkReadConcurrencyLimit: DefaultChunkReadConcurrencyLimit,
234+
ChunkWriteConcurrencyLimit: DefaultChunkWriteConcurrencyLimit,
229235
FastForwardTTL: DefaultFastForwardTTL,
230236
ForwardedHeaders: DefaultForwardedHeaders,
231237
HealthCheck: ho.New(),

pkg/config/testdata/example.alb.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ backends:
66
keep_alive_timeout: 5m0s
77
max_idle_conns: 20
88
cache_name: default
9+
chunk_read_concurrency_limit: 16
10+
chunk_write_concurrency_limit: 16
911
healthcheck: {}
1012
timeseries_retention_factor: 1024
1113
timeseries_eviction_method: oldest
@@ -37,6 +39,8 @@ backends:
3739
keep_alive_timeout: 5m0s
3840
max_idle_conns: 20
3941
cache_name: default
42+
chunk_read_concurrency_limit: 16
43+
chunk_write_concurrency_limit: 16
4044
healthcheck:
4145
interval: 1s
4246
path: /health
@@ -70,6 +74,8 @@ backends:
7074
keep_alive_timeout: 5m0s
7175
max_idle_conns: 20
7276
cache_name: default
77+
chunk_read_concurrency_limit: 16
78+
chunk_write_concurrency_limit: 16
7379
healthcheck:
7480
interval: 1s
7581
path: /health
@@ -103,6 +109,8 @@ backends:
103109
keep_alive_timeout: 5m0s
104110
max_idle_conns: 20
105111
cache_name: default
112+
chunk_read_concurrency_limit: 16
113+
chunk_write_concurrency_limit: 16
106114
healthcheck:
107115
interval: 1s
108116
timeseries_retention_factor: 1024
@@ -135,6 +143,8 @@ backends:
135143
keep_alive_timeout: 5m0s
136144
max_idle_conns: 20
137145
cache_name: default
146+
chunk_read_concurrency_limit: 16
147+
chunk_write_concurrency_limit: 16
138148
healthcheck:
139149
interval: 1s
140150
timeseries_retention_factor: 1024
@@ -166,6 +176,8 @@ backends:
166176
keep_alive_timeout: 5m0s
167177
max_idle_conns: 20
168178
cache_name: default
179+
chunk_read_concurrency_limit: 16
180+
chunk_write_concurrency_limit: 16
169181
healthcheck: {}
170182
timeseries_retention_factor: 1024
171183
timeseries_eviction_method: oldest
@@ -201,6 +213,8 @@ backends:
201213
keep_alive_timeout: 5m0s
202214
max_idle_conns: 20
203215
cache_name: default
216+
chunk_read_concurrency_limit: 16
217+
chunk_write_concurrency_limit: 16
204218
healthcheck: {}
205219
timeseries_retention_factor: 1024
206220
timeseries_eviction_method: oldest

pkg/config/testdata/example.auth.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ backends:
88
keep_alive_timeout: 5m0s
99
max_idle_conns: 20
1010
cache_name: default
11+
chunk_read_concurrency_limit: 16
12+
chunk_write_concurrency_limit: 16
1113
healthcheck: {}
1214
timeseries_retention_factor: 1024
1315
timeseries_eviction_method: oldest
@@ -40,6 +42,8 @@ backends:
4042
keep_alive_timeout: 5m0s
4143
max_idle_conns: 20
4244
cache_name: default
45+
chunk_read_concurrency_limit: 16
46+
chunk_write_concurrency_limit: 16
4347
healthcheck: {}
4448
timeseries_retention_factor: 1024
4549
timeseries_eviction_method: oldest
@@ -72,6 +76,8 @@ backends:
7276
keep_alive_timeout: 5m0s
7377
max_idle_conns: 20
7478
cache_name: default
79+
chunk_read_concurrency_limit: 16
80+
chunk_write_concurrency_limit: 16
7581
healthcheck: {}
7682
timeseries_retention_factor: 1024
7783
timeseries_eviction_method: oldest
@@ -102,6 +108,8 @@ backends:
102108
keep_alive_timeout: 5m0s
103109
max_idle_conns: 20
104110
cache_name: default
111+
chunk_read_concurrency_limit: 16
112+
chunk_write_concurrency_limit: 16
105113
healthcheck: {}
106114
timeseries_retention_factor: 1024
107115
timeseries_eviction_method: oldest

pkg/config/testdata/example.full.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ backends:
88
keep_alive_timeout: 5m0s
99
max_idle_conns: 20
1010
cache_name: default
11+
chunk_read_concurrency_limit: 16
12+
chunk_write_concurrency_limit: 16
1113
healthcheck: {}
1214
timeseries_retention_factor: 1024
1315
timeseries_eviction_method: oldest

pkg/config/testdata/exmple.sharding.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ backends:
88
keep_alive_timeout: 5m0s
99
max_idle_conns: 20
1010
cache_name: default
11+
chunk_read_concurrency_limit: 16
12+
chunk_write_concurrency_limit: 16
1113
healthcheck: {}
1214
timeseries_retention_factor: 1024
1315
timeseries_eviction_method: oldest

pkg/config/testdata/simple.prometheus.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ backends:
88
keep_alive_timeout: 5m0s
99
max_idle_conns: 20
1010
cache_name: default
11+
chunk_read_concurrency_limit: 16
12+
chunk_write_concurrency_limit: 16
1113
healthcheck: {}
1214
timeseries_retention_factor: 1024
1315
timeseries_eviction_method: oldest

pkg/config/testdata/simple.reverseproxycache.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ backends:
88
keep_alive_timeout: 5m0s
99
max_idle_conns: 20
1010
cache_name: default
11+
chunk_read_concurrency_limit: 16
12+
chunk_write_concurrency_limit: 16
1113
healthcheck: {}
1214
timeseries_retention_factor: 1024
1315
timeseries_eviction_method: oldest

0 commit comments

Comments
 (0)