Skip to content

Conversation

afhassan
Copy link
Contributor

@afhassan afhassan commented Aug 23, 2023

What this PR does:

This PR introduces a protobuf codec for encoding query range and instant query responses returned from Querier to Query Frontend (QFE). Protobuf encoding significantly reduces the latency between Querier and QFE for large size query response as it is much faster than json encoding. The new protobuf codec converts PromQL responses to a PrometheusResponse and then marshals it to Protobuf. Once the marshalled response is returned to QFE it is deserialized and merged with other responses if the query was sharded.

The PR also introduces a new config to specify the response compression. Currently the supported values are "" (no compression) or "gzip"

For unsharded instant-query requests, a JSON response is returned.

The impact on an unsharded range query with 1M samples is shown in the images below:
{__name__=~'metric_([0-9]|[1-9][0-9])'}

Before:
image

After:
image

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@justinjung04
Copy link
Contributor

@afhassan could you fix the DCO that's failing?

@yeya24
Copy link
Contributor

yeya24 commented Aug 5, 2024

Revisiting this PR, it looks like with the current version of Prometheus, we don't need a dedicated Prometheus handler anymore.
You can implement a new Codec for protobuf and use it in Prometheus API. https://github.com/prometheus/prometheus/blob/main/web/api/v1/api.go#L284

afhassan and others added 21 commits August 6, 2024 06:04
Signed-off-by: Ahmed Hassan <[email protected]>
Signed-off-by: Ahmed Hassan <[email protected]>
Signed-off-by: afayek <[email protected]>
Signed-off-by: Ahmed Hassan <[email protected]>
Signed-off-by: Ahmed Hassan <[email protected]>
Signed-off-by: Ahmed Hassan <[email protected]>
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Can we update the PR title to make it more descriptive so that reviewers can understand the change? Also the PR description is outdated.

Let's also add a changelog entry

@afhassan afhassan changed the title Reduce latency between querier and query-frontend Add protobuf codec for query range and instant query responses Sep 24, 2024
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://cortexmetrics.io/docs/configuration/v1guarantees/#experimental-features

Sorry for the back and forth. Can we also mention it as an experimental feature?

@yeya24 yeya24 merged commit 409f065 into cortexproject:master Sep 25, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants