capistrant opened a new pull request #10284:
URL: https://github.com/apache/druid/pull/10284


   <!-- Thanks for trying to help us make Apache Druid be the best it can be! 
Please fill out as much of the following information as is possible (where 
relevant, and remove it when irrelevant) to help make the intention and scope 
of this PR clear in order to ease review. -->
   
   <!-- Replace XXXX with the id of the issue fixed in this PR. Remove this 
section if there is no corresponding issue. Don't reference the issue in the 
title of this pull-request. -->
   
   <!-- If you are a committer, follow the PR action item checklist for 
committers:
   
https://github.com/apache/druid/blob/master/dev/committer-instructions.md#pr-and-issue-action-item-checklist-for-committers.
 -->
   
   ### Description
   
   <!-- Describe the goal of this PR, what problem are you fixing. If there is 
a corresponding issue (referenced above), it's not necessary to repeat the 
description here, however, you may choose to keep one summary sentence. -->
   
   A large cluster with many segments results in a lot of work being done by 
the Coordinator in order to complete its duties. I believe that any 
optimization to coordinator duties can help in a large cluster. This patch 
gives an experienced admin a knob to turn in order to try and shave some time 
off of the balance segments duty. As of now, existing Balancer Strategies 
iterate over all of the segments in the cluster when choosing a segment to 
move. The first segment candidate is the most likely to be moved and the last 
segment candidate is the least likely to move. This patch gives an admin the 
ability to put a limit on the number of segments that will be candidates to be 
moved. For most cases, I don't think this knob will be needed, but in some 
large enterprise cases I feel that it could be beneficial.
   
   <!-- Describe your patch: what did you change in code? How did you fix the 
problem? -->
   I updated the BalancerStrategy Interface. The pickSegmentToMove method 
gained a 3rd parameter that specifies the number of segments that should be 
considered when picking a segment to move. 
   
   `CostBalancerStrategy` (and it's inheriting classes) and 
`RandomBalancerStrategy` both leverage `ReservoirSegmentSampler` to choose a 
segment "at random" from a list of candidate servers. I updated the required 
method in `ReservoirSegmentSampler` to adhere to the limiting parameter 
described above. If the limit is reached, the method picking a segment will 
break out of its iteration and return immediately.
   
   Currently all code paths use a new dynamic coordinator config that an admin 
can tune if they'd like to put a limiter on this action of picking a segment to 
move. The default value for the config is such that all segments will be 
iterated and be candidates to pick. I thought a dynamic config was good because 
it is flexible and could be leveraged in times such as if you wanted to 
temporarily boost up the number of segments to move in order rebalance to new 
servers faster. If doing that, and you also wanted to make this go quicker by 
not bothering with having so many potential segments to be picked to move.
   
   The new dynamic config is `maxSegmentsToConsiderPerMove` with a default of 
`Integer.MAX_VALUE`
   
   I call out in the documentation that an admin should be experienced when 
considering altering this config. I say that because in many cases, the default 
is fine.
   
   <!--
   In each section, please describe design decisions made, including:
    - Choice of algorithms
    - Behavioral aspects. What configuration values are acceptable? How are 
corner cases and error conditions handled, such as when there are insufficient 
resources?
    - Class organization and design (how the logic is split between classes, 
inheritance, composition, design patterns)
    - Method organization and design (how the logic is split between methods, 
parameters and return types)
    - Naming (class, method, API, configuration, HTTP endpoint, names of 
emitted metrics)
   -->
   
   <!-- It's good to describe an alternative design (or mention an alternative 
name) for every design (or naming) decision point and compare the alternatives 
with the designs that you've implemented (or the names you've chosen) to 
highlight the advantages of the chosen designs and names. -->
   
   An alternative of this approach would be to restrict what is sent to 
`pickSegmentToMove` in the first place. I choose not to approach this at this 
time because I didn't like the idea of either choosing the number of 
`ServerHolders` to send to `pickSegmentsToMove` or to analyze the 
`ServerHolders` before picking how many to send to ensure only a certain number 
of segments are sent. I'd be open to re-assessing whether or not this would be 
a better approach or not if someone suggests it may be the proper approach.
   
   <!-- If there was a discussion of the design of the feature implemented in 
this PR elsewhere (e. g. a "Proposal" issue, any other issue, or a thread in 
the development mailing list), link to that discussion from this PR description 
and explain what have changed in your final design compared to your original 
proposal or the consensus version in the end of the discussion. If something 
hasn't changed since the original discussion, you can omit a detailed 
discussion of those aspects of the design here, perhaps apart from brief 
mentioning for the sake of readability of this PR description. -->
   
   <!-- Some of the aspects mentioned above may be omitted for simple and small 
changes. -->
   
   <hr>
   
   This PR has:
   - [X] been self-reviewed.
   - [X] added documentation for new or modified features or behaviors.
   - [X] added Javadocs for most classes and all non-trivial methods. Linked 
related entities via Javadoc links.
   - [X] added comments explaining the "why" and the intent of the code 
wherever would not be obvious for an unfamiliar reader.
   - [X] added unit tests or modified existing tests to cover new code paths, 
ensuring the threshold for [code 
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
 is met.
   - [X] been tested in a test Druid cluster.
   
   <!-- Check the items by putting "x" in the brackets for the done things. Not 
all of these items apply to every PR. Remove the items which are not done or 
not relevant to the PR. None of the items from the checklist above are strictly 
necessary, but it would be very helpful if you at least self-review the PR. -->
   
   <hr>
   
   ##### Key changed/added classes in this PR
    * `BalancerStrategy` Interface
     * `CostBalancerStrategy`
     * `RandomBalancerStrategy`
   * `ReservoirSegmentSampler`
   * `CoordinatorDynamicConfig`
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to