Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoscaling: add querier predictive scaling #7775

Merged
merged 8 commits into from
Apr 26, 2024

Conversation

dimitarvdimitrov
Copy link
Contributor

This PR upstreams a change that we have been trialing at GL.

Problem

Some workloads have a very uneven distribution of queries. Some of the causes of this can be external alerting systems and reporting tools which run batch jobs once a day.

This results in an influx of queries at fairly regular intervals (~24h). Autoscaling can only respond so fast to incoming queries. In practice, it takes anywhere between 2 and 7 minutes to respond to queries and trigger a scaling event. As a result Mimir's query queues fill up and Mimir start returning HTTP 429 to new queries until queriers have had the time to scale out and accommodate the added load.

Solution

Scale preemptively. Automated workloads are also highly predictive. This PR uses the value of the inflight queries at the same time last week (6d23h30m instead of 7d) to prepare for periodic queries.

Results

We've seen HTTP 429 responses decrease significantly on a weekly basis: between 66% and 95%
Screenshot 2024-04-02 at 15 13 41

Side effects

There are a lot of false-positive scaling events. As a result of this we've seen querier cost increase between 20% and 50%. Given that querier cost is usually 1-2% of the cell's TCO, this is somewhat acceptable for a better QoS.

Checklist

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

@dimitarvdimitrov dimitarvdimitrov requested a review from a team as a code owner April 2, 2024 14:00
@dimitarvdimitrov dimitarvdimitrov changed the title autoscaling: add autoscaling_querier_predictive_scaling_enabled autoscaling: add querier predictive scaling Apr 2, 2024
Copy link
Contributor

@charleskorn charleskorn left a comment

Choose a reason for hiding this comment

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

LGTM modulo typo below.

Is it worth making the lookback (currently 7d) and range (currently 30m) configurable? I could imagine different Mimir clusters could have different query patterns.

operations/mimir/autoscaling.libsonnet Outdated Show resolved Hide resolved
@dimitarvdimitrov dimitarvdimitrov force-pushed the dimitar/jsonnet/querier-predictive-scaling branch from b17cc1a to f550086 Compare April 3, 2024 13:47
@dimitarvdimitrov
Copy link
Contributor Author

Is it worth making the lookback (currently 7d) and range (currently 30m) configurable? I could imagine different Mimir clusters could have different query patterns.

Added in a4ba23b

operations/mimir/autoscaling.libsonnet Outdated Show resolved Hide resolved
operations/mimir/autoscaling.libsonnet Outdated Show resolved Hide resolved
operations/mimir/autoscaling.libsonnet Outdated Show resolved Hide resolved
@dimitarvdimitrov
Copy link
Contributor Author

thanks for the review and sorry for the numerous typos 🙈 can you take another pass @charleskorn?

dimitarvdimitrov and others added 7 commits April 12, 2024 14:59
This PR upstreams a change that we have been trialing at GL.

### Problem

Some workloads have a very uneven distribution of queries. Some of the causes of this can be external alerting systems and reporting tools which run batch jobs once a day.

This results in an influx of queries at fairly regular intervals (~24h). Autoscaling can only respond so fast to incoming queries. In practice, it takes anywhere between 2 and 7 minutes to respond to queries and trigger a scaling event. As a result Mimir's query queues fill up and Mimir start returning HTTP 429 to new queries until queriers have had the time to scale out and accommodate the added load.

### Solution

Scale preemptively. Automated workloads are also highly predictive. This PR uses the value of the inflight queries at the same time last week (6d23h30m instead of 7d) to prepare for periodic queries.

### Results

We've seen HTTP 429 responses decrease significantly on a weekly basis: between 66% and 95%

### Side effects

There are a lot of false-positive scaling events. As a result of this we've seen querier cost increase between 20% and 50%. Given that querier cost is usually 1-2% of the cell's TCO, this is somewhat acceptable for a better QoS.

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
Co-authored-by: Charles Korn <charleskorn@users.noreply.github.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
@dimitarvdimitrov dimitarvdimitrov force-pushed the dimitar/jsonnet/querier-predictive-scaling branch from 44b3e3e to 4db5b1d Compare April 12, 2024 13:02
Copy link
Collaborator

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

Nice work! Have you considered enabling it in operations/mimir-tests/test-autoscaling.jsonnet?

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
@dimitarvdimitrov dimitarvdimitrov enabled auto-merge (squash) April 26, 2024 10:03
@dimitarvdimitrov dimitarvdimitrov merged commit cf2c9db into main Apr 26, 2024
31 checks passed
@dimitarvdimitrov dimitarvdimitrov deleted the dimitar/jsonnet/querier-predictive-scaling branch April 26, 2024 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants