Skip to content

Commit c4405fe

Browse files
feat: WAL Manager configuration options (#13531)
1 parent ba57054 commit c4405fe

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

docs/sources/shared/configuration.md

+19
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,25 @@ ingester_rf1:
316316
# CLI flag: -ingester-rf1.flush-op-timeout
317317
[flush_op_timeout: <duration> | default = 10m]
318318

319+
# The maximum age of a segment before it should be flushed. Increasing this
320+
# value allows more time for a segment to grow to max-segment-size, but may
321+
# increase latency if the write volume is too small.
322+
# CLI flag: -ingester-rf1.max-segment-age
323+
[max_segment_age: <duration> | default = 500ms]
324+
325+
# The maximum size of a segment before it should be flushed. It is not a
326+
# strict limit, and segments can exceed the maximum size when individual
327+
# appends are larger than the remaining capacity.
328+
# CLI flag: -ingester-rf1.max-segment-size
329+
[max_segment_size: <int> | default = 8388608]
330+
331+
# The maximum number of segments to buffer in-memory. Increasing this value
332+
# allows for large bursts of writes to be buffered in memory, but may increase
333+
# latency if the write volume exceeds the rate at which segments can be
334+
# flushed.
335+
# CLI flag: -ingester-rf1.max-segments
336+
[max_segments: <int> | default = 10]
337+
319338
# How long chunks should be retained in-memory after they've been flushed.
320339
# CLI flag: -ingester-rf1.chunks-retain-period
321340
[chunk_retain_period: <duration> | default = 0s]

pkg/ingester-rf1/ingester.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ type Config struct {
7474
FlushCheckPeriod time.Duration `yaml:"flush_check_period"`
7575
FlushOpBackoff backoff.Config `yaml:"flush_op_backoff"`
7676
FlushOpTimeout time.Duration `yaml:"flush_op_timeout"`
77+
MaxSegmentAge time.Duration `yaml:"max_segment_age"`
78+
MaxSegmentSize int `yaml:"max_segment_size"`
79+
MaxSegments int `yaml:"max_segments"`
7780
RetainPeriod time.Duration `yaml:"chunk_retain_period"`
7881
MaxChunkIdle time.Duration `yaml:"chunk_idle_period"`
7982
BlockSize int `yaml:"chunk_block_size"`
@@ -115,6 +118,10 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
115118
f.DurationVar(&cfg.FlushOpBackoff.MaxBackoff, "ingester-rf1.flush-op-backoff-max-period", time.Minute, "Maximum backoff period when a flush fails. Each concurrent flush has its own backoff, see `ingester.concurrent-flushes`.")
116119
f.IntVar(&cfg.FlushOpBackoff.MaxRetries, "ingester-rf1.flush-op-backoff-retries", 10, "Maximum retries for failed flushes.")
117120
f.DurationVar(&cfg.FlushOpTimeout, "ingester-rf1.flush-op-timeout", 10*time.Minute, "The timeout for an individual flush. Will be retried up to `flush-op-backoff-retries` times.")
121+
f.DurationVar(&cfg.MaxSegmentAge, "ingester-rf1.max-segment-age", 500*time.Millisecond, "The maximum age of a segment before it should be flushed. Increasing this value allows more time for a segment to grow to max-segment-size, but may increase latency if the write volume is too small.")
122+
f.IntVar(&cfg.MaxSegmentSize, "ingester-rf1.max-segment-size", 8*1024*1024, "The maximum size of a segment before it should be flushed. It is not a strict limit, and segments can exceed the maximum size when individual appends are larger than the remaining capacity.")
123+
f.IntVar(&cfg.MaxSegments, "ingester-rf1.max-segments", 10, "The maximum number of segments to buffer in-memory. Increasing this value allows for large bursts of writes to be buffered in memory, but may increase latency if the write volume exceeds the rate at which segments can be flushed.")
124+
118125
f.DurationVar(&cfg.RetainPeriod, "ingester-rf1.chunks-retain-period", 0, "How long chunks should be retained in-memory after they've been flushed.")
119126
// f.DurationVar(&cfg.MaxChunkIdle, "ingester-rf1.chunks-idle-period", 30*time.Minute, "How long chunks should sit in-memory with no updates before being flushed if they don't hit the max block size. This means that half-empty chunks will still be flushed after a certain period as long as they receive no further activity.")
120127
f.IntVar(&cfg.BlockSize, "ingester-rf1.chunks-block-size", 256*1024, "The targeted _uncompressed_ size in bytes of a chunk block When this threshold is exceeded the head block will be cut and compressed inside the chunk.")
@@ -254,9 +261,9 @@ func New(cfg Config, clientConfig client.Config,
254261
metrics := newIngesterMetrics(registerer, metricsNamespace)
255262

256263
walManager, err := wal.NewManager(wal.Config{
257-
MaxAge: wal.DefaultMaxAge,
258-
MaxSegments: wal.DefaultMaxSegments,
259-
MaxSegmentSize: wal.DefaultMaxSegmentSize,
264+
MaxAge: cfg.MaxSegmentAge,
265+
MaxSegments: int64(cfg.MaxSegments),
266+
MaxSegmentSize: int64(cfg.MaxSegmentSize),
260267
}, wal.NewMetrics(registerer))
261268
if err != nil {
262269
return nil, err

0 commit comments

Comments
 (0)