Skip to content

Randomly distribute queries across store-gateways #3824

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

Merged

Conversation

pracucci
Copy link
Contributor

What this PR does:
Currently, when the querier needs to query a block it always pick the 1st store-gateway holding that block (1st is based on the tokens in the ring). This may cause to have hot store-gateways instead of balancing the traffic across all store-gateways holding a specific block (eg. 3 when the replication factor is set to 3).

This PR fixes it, randomly selecting a store-gateway.

Which issue(s) this PR fixes:
N/A

Checklist

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

Signed-off-by: Marco Pracucci <marco@pracucci.com>
Copy link
Contributor

@jtlisi jtlisi left a comment

Choose a reason for hiding this comment

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

LGTM

@stevesg
Copy link
Contributor

stevesg commented Feb 16, 2021

Looks good, only one question:

Am I right in thinking that whilst two balancing policies are defined, only randomLoadBalancing is used? (though the noLoadBalancing policy is used in the unit test).

I might be missing some context on the issue - is there a plan to allow configuring which policy to use, or add more policies? If it's always going to be randomLoadBalancing, then the configurable policies could be omitted, saving a little glue code.

@pracucci
Copy link
Contributor Author

Am I right in thinking that whilst two balancing policies are defined, only randomLoadBalancing is used? (though the noLoadBalancing policy is used in the unit test).

Correct. Introducing randomness in unit tests would require to change the unit tests in a way what would lower the confidence on the algorithm, reason why I preferred to not have it.

I might be missing some context on the issue - is there a plan to allow configuring which policy to use, or add more policies? If it's always going to be randomLoadBalancing, then the configurable policies could be omitted, saving a little glue code.

I think we should keep randomLoadBalancing for real usage, without making it configurable. We already did it in blocksStoreBalancedSet (used when store-gateway sharding is disabled) while we missed to do it in blocksStoreReplicationSet (used when store-gateway sharding is enabled).

@pracucci pracucci merged commit 16265a0 into cortexproject:master Feb 16, 2021
@pracucci pracucci deleted the randomly-balance-store-gateway-requests branch February 16, 2021 10:45
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.

4 participants