Repository navigation
feat(googlecloud): add adaptive rate limiter for Cloud Logging API queries - #896
Merged
kyasbal merged 1 commit intoAug 25, 2026
Merged
Conversation
kyasbal
requested review from
K53,
RyuSA,
jyane,
kkuchima and
renamoo
as code owners
August 24, 2026 03:28
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces adaptive rate limiting for Google Cloud Logging client queries using an Additive Increase / Multiplicative Decrease (AIMD) algorithm. It adds a new ratelimit package containing the AdaptiveRateLimiter, a limiter pool, and a gRPC unary client interceptor, alongside new configuration parameters and a Float64 flag parser. The review feedback highlights two key improvements: first, suppressing rate increases during the cooldown window immediately following a rate reduction to prevent aggressive overrides; second, using grpc.WithChainUnaryInterceptor instead of grpc.WithUnaryInterceptor to avoid silently overwriting other configured interceptors.
kyasbal
commented
Aug 25, 2026
kyasbal
force-pushed
the
feat/gcp-adaptive-rate-limiter
branch
from
August 25, 2026 01:00
ddb7d31 to
b055068
Compare
kyasbal
commented
Aug 25, 2026
…eries Implement an AIMD (Additive Increase / Multiplicative Decrease) based adaptive rate limiter for Cloud Logging queries to mitigate 429 ResourceExhausted errors when querying logs in parallel. - Add pkg/api/googlecloud/ratelimit for AIMD limiter, pool, and gRPC unary interceptor - Add CLI parameters for logging rate limits (--logging-initial-qps, etc.) - Inject adaptive rate limiter into ClientFactory in APIClientFactoryOptionsTask - Add Float64 support in flag package fix(googlecloud): address PR review comments for adaptive rate limiter feat(googlecloud): tune adaptive rate limiter default parameters for faster sustained queries
kyasbal
force-pushed
the
feat/gcp-adaptive-rate-limiter
branch
from
August 25, 2026 03:01
b055068 to
c112236
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces an adaptive rate limiter for Google Cloud Logging API queries using an Additive Increase Multiplicative Decrease (AIMD) algorithm implemented as a gRPC unary client interceptor.
Background & Motivation
When KHI runs concurrent inspection tasks across multiple log types (e.g. Kubernetes Audit, Node, Container, Autoscaler, Serial Port logs), bursts of unthrottled gRPC calls easily exceed the Cloud Logging API quota limits, triggering
ResourceExhausted(429) errors.In unthrottled clients, 429 errors trigger exponential backoff retry storms (or exhaustion failures), significantly delaying log collection or causing inspection tasks to fail.
Changes
pkg/api/googlecloud/ratelimit.AdaptiveRateLimiter:golang.org/x/time/rate.Limiter.IncreaseStepon success, and multiply rate byDecreaseFactoroncodes.ResourceExhausted.DecreaseCooldownsuppression window prevents rapid consecutive throttling drops on parallel in-flight failures.pkg/api/googlecloud/ratelimit.Pool:pkg/api/googlecloud/ratelimit.UnaryClientInterceptor:pkg/parameters& CLI Flags:--logging-initial-qps,--logging-min-qps,--logging-max-qps).pkg/task/inspection/googlecloudcommon/impl.apioptions_task:ClientFactoryOptions.Verification & Benchmark Results
Under simulated quota constraints (25.0 QPS capacity, 10 concurrent workers, 100 queries):
462 ns/op,0 allocs/opon 12 parallel threads.make test-go), linters (make lint-go), and pre-commit hooks passed.