Skip to content

Commit

Permalink
enhance: Print log only when rate limit updates (milvus-io#35806)
Browse files Browse the repository at this point in the history
The debug log for "RateLimiter register for rateType" is too frequent
and in e2e cases, the may print 18M times in one run.

This PR make the log be printed only when rate limit is updated.

Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia authored Aug 29, 2024
1 parent 09ef3f1 commit 3c8941a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions internal/proxy/simple_rate_limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,22 @@ func initLimiter(rln *rlinternal.RateLimiterNode, rateLimiterConfigs map[interna
newLimit := ratelimitutil.Limit(p.GetAsFloat())
burst := p.GetAsFloat() // use rate as burst, because SimpleLimiter is with punishment mechanism, burst is insignificant.
old, ok := rln.GetLimiters().Get(rt)
updated := false
if ok {
if old.Limit() != newLimit {
old.SetLimit(newLimit)
updated = true
}
} else {
rln.GetLimiters().Insert(rt, ratelimitutil.NewLimiter(newLimit, burst))
updated = true
}
if updated {
log.Debug("RateLimiter register for rateType",
zap.String("rateType", internalpb.RateType_name[(int32(rt))]),
zap.String("rateLimit", newLimit.String()),
zap.String("burst", fmt.Sprintf("%v", burst)))
}
log.Debug("RateLimiter register for rateType",
zap.String("rateType", internalpb.RateType_name[(int32(rt))]),
zap.String("rateLimit", newLimit.String()),
zap.String("burst", fmt.Sprintf("%v", burst)))
}
}

Expand Down

0 comments on commit 3c8941a

Please sign in to comment.