Skip to content

Commit 2f1812f

Browse files
committed
Change min ratelimit calculation to per period
So when you have a short flush period it will go faster Also initialize the rate-limit to "Inf" or no limit, so we start out fast and slow down once we know what the queue is like. Signed-off-by: Bryan Boreham <[email protected]>
1 parent 4ba98fc commit 2f1812f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

pkg/ingester/flush.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const (
2020
// Backoff for retrying 'immediate' flushes. Only counts for queue
2121
// position, not wallclock time.
2222
flushBackoff = 1 * time.Second
23-
// Slowest per-second we will rate-limit flush calls to the chunk store
24-
minFlushRate = 10
23+
// Lower bound on flushes per check period for rate-limiter
24+
minFlushes = 100
2525
)
2626

2727
// Flush triggers a flush of all the chunks and closes the flush queues.
@@ -111,8 +111,8 @@ func (i *Ingester) setFlushRate() {
111111
const fudge = 1.05 // aim to finish a little bit before the end of the period
112112
flushesPerSecond := float64(totalQueueLength) / i.cfg.FlushCheckPeriod.Seconds() * fudge
113113
// Avoid going very slowly with tiny queues
114-
if flushesPerSecond < minFlushRate {
115-
flushesPerSecond = minFlushRate
114+
if flushesPerSecond*i.cfg.FlushCheckPeriod.Seconds() < minFlushes {
115+
flushesPerSecond = minFlushes / i.cfg.FlushCheckPeriod.Seconds()
116116
}
117117
level.Debug(util.Logger).Log("msg", "computed flush rate", "rate", flushesPerSecond)
118118
i.flushRateLimiter.SetLimit(rate.Limit(flushesPerSecond))

pkg/ingester/ingester.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func New(cfg Config, clientConfig client.Config, limits *validation.Overrides, c
203203
limits: limits,
204204
chunkStore: chunkStore,
205205
flushQueues: make([]*util.PriorityQueue, cfg.ConcurrentFlushes),
206-
flushRateLimiter: rate.NewLimiter(minFlushRate, 1),
206+
flushRateLimiter: rate.NewLimiter(rate.Inf, 1),
207207
usersMetadata: map[string]*userMetricsMetadata{},
208208
registerer: registerer,
209209
}

0 commit comments

Comments
 (0)