Repository navigation
fix: keep backend render coalescing opt-in for cache locality - #570
Merged
Merged
Conversation
deniszh
approved these changes
Oct 16, 2026
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.
What issue is this change attempting to solve?
Why
HTTP render coalescing reduces frontend wire overhead but can regress ordinary read latency by defeating go-carbon's response and expanded-glob caches. Enabling it by default in #567 exposed that interaction: the caches identify the complete request, rather than each logical metric. A changing batch creates unrelated cache entries even when its metrics were already read individually.
How does this change solve the problem? Why is this the best approach?
Architecture
Expanded metrics are still routed separately to each backend and retain their existing per-metric replica-majority handling. This change sets
renderBatchSizeto1in the default configuration and example, so the backend queue sends individual requests unless an operator explicitly opts in. It leaves the coalescer implementation, routing, concurrency accounting and the allocation/compression improvements from #566 intact. There is no new transport or compatibility path.The backend cache boundary matters here. go-carbon's render-cache key contains the entire target list in request order (
getRenderCacheKeyAndSize). Its expanded-glob key joins the metric-name list (getExpandedGlobsWithCache);getUniqueMetricNamessupplies that list through unsorted map iteration. Queue-dependent batch membership/order therefore loses response-cache reuse, and map iteration further fragments glob-cache reuse. Sorting alone would not fix changing batch membership.Before / after
renderBatchSizeenables batches up to 32 metrics.renderBatchSizesends individual metric requests.Usage and rollout
For an existing binary containing #567, set
renderBatchSize: 1explicitly to disable coalescing. Updating to this change makes that the default when the field is omitted; an existing explicit value above 1 must still be changed. The example configuration uses1too.Keep coalescing opt-in until backend cache reuse is independent of dynamic wire batches, and a representative production comparison passes backend CPU/allocation, cache-miss and simple-request tail-latency checks. This is a mitigation, not a cache-granularity fix; no post-mitigation production improvement is claimed here.
How can we be sure this works as expected?
go test ./pkg/cfg ./pkg/backend ./pkg/app/carbonapi ./pkg/utilpassed.go test -race ./pkg/backend ./pkg/app/carbonapi ./pkg/utilpassed, including existing coalescing output and queue-liveness tests.