Skip to content

Configurable Broker tier selection for Realtime servers#19062

Merged
abhishekrb19 merged 11 commits into
masterfrom
configurable_broker_realtime_tier_strategy
Mar 3, 2026
Merged

Configurable Broker tier selection for Realtime servers#19062
abhishekrb19 merged 11 commits into
masterfrom
configurable_broker_realtime_tier_strategy

Conversation

@abhishekrb19

@abhishekrb19 abhishekrb19 commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Currently, the Broker uses the same tier selection and balancer strategies configured by druid.broker.select.tier and druid.broker.balancer.type for both Historicals and realtime servers.

This patch allows operators to optionally override that behavior for realtime servers via the druid.broker.realtime.select.tier and druid.broker.realtime.balancer.type properties. This is useful in environments where Historicals and Realtime servers are configured differently.

  • If the new properties druid.broker.realtime.select.tier and druid.broker.realtime.balancer.type are not configured (default behavior), realtime servers will continue to use the default strategy or the one configured via druid.broker.select.tier and druid.broker.select.balancer.type, for backward compatibility.
  • All the balancer and tier selection strategies are applicable to the realtime ones as well

Approach:

  • Add a separate module BrokerRealtimeSelectorModule that's added to CliBroker
  • This module is essentially named providers for realtime servers' - TierSelectorStrategy and ServerSelectorStrategy
  • By default, if this isn't configured, the default ones configured from druid.broker.balancer.type and druid.broker.select.tier are applied for the realtime servers (backward compatible behavior)

While at it, I also added toString() and related helpers for TierSelectorStrategy implementations to improve debuggability and test verification.

I can document this configuration separately, since the relevant sections in the existing docs for druid.broker.select.tier could also use an update.

Release note:

Added druid.broker.realtime.select.tier and druid.broker.realtime.balancer.type on the Brokers to optionally override the Broker’s tier selection and balancer strategies for realtime servers. If these properties are unset (by default), realtime servers continue to use the existing druid.broker.select and druid.broker.balancer configurations that applies to both historical and realtime servers.

This PR has:

  • been self-reviewed.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • been tested in a test Druid cluster.

Comment thread server/src/main/java/org/apache/druid/client/selector/ServerSelector.java Dismissed
Comment thread server/src/main/java/org/apache/druid/client/selector/ServerSelector.java Dismissed
Currently the BrokerServerView shares the same strategy configured by
druid.broker.select.tier for both historicals and realtime servers.

This patch allows operators to optionally overide that behavior based on how
realtime servers are setup via druid.broker.select.realtime.tier property.

If this property isn't specified, the realtime servers' strategy will continue
to share the historical's strategy (backwards compatble).
@abhishekrb19 abhishekrb19 force-pushed the configurable_broker_realtime_tier_strategy branch from 5e5a322 to 441f48d Compare February 26, 2026 22:49
@abhishekrb19 abhishekrb19 force-pushed the configurable_broker_realtime_tier_strategy branch from 734a358 to fd405ba Compare February 27, 2026 18:03
public String toString()
{
return "PreferredTierSelectorStrategy{" +
", config=" + config +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
", config=" + config +
"config=" + config +

final FilteredServerInventoryView baseView,
final TierSelectorStrategy tierSelectorStrategy,
final TierSelectorStrategy historicalTierSelectorStrategy,
@Named(REALTIME_SELECTOR) final TierSelectorStrategy realtimeTierSelectorStrategy,

@aho135 aho135 Mar 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we also have @Named for historicalTierSelectorStrategy? This makes things more explicit in the test code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm agreed, that would make it clearer for the historical one as well. However, it would require introducing a separate provider to bind the @Named variant and move the existing bindings from CliBroker, since the same class cannot be bound multiple times in Guice. I punted on that for now in favor of a brief comment here indicating where these bindings are injected from. Hopefully that clarifies it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ahh I see, thanks for clarifying. Makes sense, and the comments help!

instanceof LowestPriorityTierSelectorStrategy
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we have one additional test case for the Preferred strategy just to validate the bindings? Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for calling that out! Added tests for PreferredTierSelectorStrategy as well.

@abhishekrb19 abhishekrb19 merged commit 2a5ba3e into master Mar 3, 2026
62 of 63 checks passed
@abhishekrb19 abhishekrb19 deleted the configurable_broker_realtime_tier_strategy branch March 3, 2026 20:54
@github-actions github-actions Bot added this to the 37.0.0 milestone Mar 3, 2026
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