-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Query frontend: dynamic vertical shards number #5618
Comments
Mhm, how would the user know how many shards they need? In Grafana, for example, this would mean many data sources with different parameters. It would be pretty bad UX IMO. I was thinking about this: how about making a cached call to /api/v1/series to see what series are available beforehand and then calculating the optimum number of shards according to the aggregating labels? So, the matchers would be the same as in query plus the aggregating labels should be not empty. The downside of such solution is that it means an extra call and that this call could return a lot of info but perhaps we could limit the results to some number of series? Just my 2 cents. But I'd rather avoid having many data-sources 🤔 Finally, we could still add the ability to override the number of shards but I don't think it should be the "final" solution. |
typically it could be calculated by cpu cores and querier instance count? |
I agree with you. Ideally the shard number needs to be calculated automatically by a component in query frontend and it knows the cardinality of metrics. Right now, I am just thinking about exposing this and users can configure the shards from API call. They can choose num shards based on experiences first. Another use case is to disable sharding for some queries. For Grafana, I would say it is a Grafana UX issue. Panels don't support custom Params overwriting. |
I believe rulers also don't support custom URL parameters right now, which is something we can add to control shards per rule / ruler. |
We may need to find a better solution as adding num shards configuration to rule file is a breaking change. If our final goal is to determine the shards automatically then this field needs to be deprecated anyway. |
Could we use a query comment to specific the shard num?
The ideal comes from mysql sharding use sql comment. |
Does promql support comment? And this would require the engine be shards aware as well. |
@yeya24 promql support comment. |
Hello 👋 Looks like there was no activity on this issue for the last two months. |
Still valid |
Is your proposal related to a problem?
The idea was originally mentioned in #5342 (comment).
Right now the number of vertical query shards is a static value configured via the query frontend flag. However, different metrics may have different cardinalities, thus causing the static vertical shards value cannot fit well for all cases. Some queries are sufficient for 1 shard while some queries might need more shards.
Describe the solution you'd like
vertical_shards
orshards
to specify the number of shards to use. If this value is specified, use it instead. The param is only valid in query frontend but not valid in querier (since only query frontend needs to set the shards).query-frontend.max-vertical-shards
to limit the max number of shards we allow.Additional context
Ideally more dynamic sharding can be enabled by estimating the cardinality of the given queries and changing the shards.
One caveat:
The text was updated successfully, but these errors were encountered: