You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "jtuglu1 (via GitHub)" <gi...@apache.org> on 2025/09/04 06:12:37 UTC

[PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

jtuglu1 opened a new pull request, #18480:
URL: https://github.com/apache/druid/pull/18480

   <!-- 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. -->
   
   <!-- Please read the doc for contribution (https://github.com/apache/druid/blob/master/CONTRIBUTING.md) before making this PR. Also, once you open a PR, please _avoid using force pushes and rebasing_ since these make it difficult for reviewers to see what you've changed in response to their reviews. See [the 'If your pull request shows conflicts with master' section](https://github.com/apache/druid/blob/master/CONTRIBUTING.md#if-your-pull-request-shows-conflicts-with-master) for more details. -->
   <!-- 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. -->
   
   <!-- Describe your patch: what did you change in code? How did you fix the problem? -->
   
   <!-- If there are several relatively logically separate changes in this PR, create a mini-section for each of them. For example: -->
   
   Allows the maximum number of stopped tasks to scale proportional to the task autoscaler. This is useful in cases where scaling up/down a lot can mess up the (over/under) # of tasks being marked for publishing.
   
   <!--
   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. -->
   
   <!-- 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. -->
   
   #### Release note
   <!-- Give your best effort to summarize your changes in a couple of sentences aimed toward Druid users. 
   
   If your change doesn't have end user impact, you can skip this section.
   
   For tips about how to write a good release note, see [Release notes](https://github.com/apache/druid/blob/master/CONTRIBUTING.md#release-notes).
   
   -->
   
   
   <hr>
   
   ##### Key changed/added classes in this PR
    * `MyFoo`
    * `OurBar`
    * `TheirBaz`
   
   <hr>
   
   <!-- 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 below are strictly necessary, but it would be very helpful if you at least self-review the PR. -->
   
   This PR has:
   
   - [ ] been self-reviewed.
      - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] 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 or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [ ] 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](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "jtuglu1 (via GitHub)" <gi...@apache.org>.
jtuglu1 commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2325443828


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -100,6 +103,9 @@ public LagBasedAutoScalerConfig(
     this.scaleOutStep = scaleOutStep != null ? scaleOutStep : 2;
     this.minTriggerScaleActionFrequencyMillis = minTriggerScaleActionFrequencyMillis
         != null ? minTriggerScaleActionFrequencyMillis : 600000;
+
+    Preconditions.checkArgument(stopTaskCountPercent == null || (stopTaskCountPercent > 0.0 && stopTaskCountPercent <= 1.0), "0.0 < stopTaskCountPercent <= 1.0");

Review Comment:
   I don't really like the idea of using an int field for this kind of thing. I'll switch the name to ratio.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "jtuglu1 (via GitHub)" <gi...@apache.org>.
jtuglu1 commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2328458319


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -49,6 +50,7 @@ public class LagBasedAutoScalerConfig implements AutoScalerConfig
   private final boolean enableTaskAutoScaler;
   private final long minTriggerScaleActionFrequencyMillis;
   private final AggregateFunction lagAggregate;
+  @Nullable private Double stopTaskCountPercent;

Review Comment:
   > I just meant we should drop the @Nullable from @Nullable private Double stopTaskCountPercent
   
   I personally like to mark these things as `@Nullable` or `Optional<T>` as it makes it clear when working the raw value that the value could be null (not just return value of the accessor method). In that case `startTaskCount` annotation should also be changed. We should have a clear standard on these things (like [this](https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations)) so style doesn't differ based on who is reviewing.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "jtuglu1 (via GitHub)" <gi...@apache.org>.
jtuglu1 commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2325443828


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -100,6 +103,9 @@ public LagBasedAutoScalerConfig(
     this.scaleOutStep = scaleOutStep != null ? scaleOutStep : 2;
     this.minTriggerScaleActionFrequencyMillis = minTriggerScaleActionFrequencyMillis
         != null ? minTriggerScaleActionFrequencyMillis : 600000;
+
+    Preconditions.checkArgument(stopTaskCountPercent == null || (stopTaskCountPercent > 0.0 && stopTaskCountPercent <= 1.0), "0.0 < stopTaskCountPercent <= 1.0");

Review Comment:
   Value range is (0, 1.]. I don't really like the idea of using an int field for this kind of thing. I'll switch the name to ratio.



##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -100,6 +103,9 @@ public LagBasedAutoScalerConfig(
     this.scaleOutStep = scaleOutStep != null ? scaleOutStep : 2;
     this.minTriggerScaleActionFrequencyMillis = minTriggerScaleActionFrequencyMillis
         != null ? minTriggerScaleActionFrequencyMillis : 600000;
+
+    Preconditions.checkArgument(stopTaskCountPercent == null || (stopTaskCountPercent > 0.0 && stopTaskCountPercent <= 1.0), "0.0 < stopTaskCountPercent <= 1.0");

Review Comment:
   Value range is (0, 1.0]. I don't really like the idea of using an int field for this kind of thing. I'll switch the name to ratio.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "jtuglu1 (via GitHub)" <gi...@apache.org>.
jtuglu1 commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2328458319


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -49,6 +50,7 @@ public class LagBasedAutoScalerConfig implements AutoScalerConfig
   private final boolean enableTaskAutoScaler;
   private final long minTriggerScaleActionFrequencyMillis;
   private final AggregateFunction lagAggregate;
+  @Nullable private Double stopTaskCountPercent;

Review Comment:
   > I just meant we should drop the @Nullable from @Nullable private Double stopTaskCountPercent
   
   I personally like to mark these things as `@Nullable` as it makes it clear when working the raw value that the value could be null (not just the accessor method). In that case `startTaskCount` annotation should also be changed. We should have a clear standard on these things (like [this](https://google.github.io/styleguide/javaguide.html) so style doesn't differ based on who is reviewing.



##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -49,6 +50,7 @@ public class LagBasedAutoScalerConfig implements AutoScalerConfig
   private final boolean enableTaskAutoScaler;
   private final long minTriggerScaleActionFrequencyMillis;
   private final AggregateFunction lagAggregate;
+  @Nullable private Double stopTaskCountPercent;

Review Comment:
   > I just meant we should drop the @Nullable from @Nullable private Double stopTaskCountPercent
   
   I personally like to mark these things as `@Nullable` as it makes it clear when working the raw value that the value could be null (not just the accessor method). In that case `startTaskCount` annotation should also be changed. We should have a clear standard on these things (like [this](https://google.github.io/styleguide/javaguide.html)) so style doesn't differ based on who is reviewing.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "jtuglu1 (via GitHub)" <gi...@apache.org>.
jtuglu1 commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2328458319


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -49,6 +50,7 @@ public class LagBasedAutoScalerConfig implements AutoScalerConfig
   private final boolean enableTaskAutoScaler;
   private final long minTriggerScaleActionFrequencyMillis;
   private final AggregateFunction lagAggregate;
+  @Nullable private Double stopTaskCountPercent;

Review Comment:
   > I just meant we should drop the @Nullable from @Nullable private Double stopTaskCountPercent
   
   I personally like to mark these things as `@Nullable` as it makes it clear when working the raw value that the value could be null (not just return value of the accessor method). In that case `startTaskCount` annotation should also be changed. We should have a clear standard on these things (like [this](https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations)) so style doesn't differ based on who is reviewing.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "jtuglu1 (via GitHub)" <gi...@apache.org>.
jtuglu1 commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2325449655


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -212,6 +218,15 @@ public AggregateFunction getLagAggregate()
     return lagAggregate;
   }
 
+  @Override
+  @JsonProperty
+  @Nullable
+  @JsonInclude(JsonInclude.Include.NON_NULL)

Review Comment:
   Hmmm. Are we sure we want to do that? This would exclude ALL fields that are `null`. In the case where there's some malformed input we may not include it in the spec at all (not visible to the user). I'd prefer to reserve this for fields which make sense to be nullable.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "jtuglu1 (via GitHub)" <gi...@apache.org>.
jtuglu1 commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2328458319


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -49,6 +50,7 @@ public class LagBasedAutoScalerConfig implements AutoScalerConfig
   private final boolean enableTaskAutoScaler;
   private final long minTriggerScaleActionFrequencyMillis;
   private final AggregateFunction lagAggregate;
+  @Nullable private Double stopTaskCountPercent;

Review Comment:
   > I just meant we should drop the @Nullable from @Nullable private Double stopTaskCountPercent
   
   In that case `startTaskCount` annotation should also be changed. We should have a clear standard on these things so style doesn't differ based on who is reviewing.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "jtuglu1 (via GitHub)" <gi...@apache.org>.
jtuglu1 commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2325449655


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -212,6 +218,15 @@ public AggregateFunction getLagAggregate()
     return lagAggregate;
   }
 
+  @Override
+  @JsonProperty
+  @Nullable
+  @JsonInclude(JsonInclude.Include.NON_NULL)

Review Comment:
   Hmmm. Are we sure we want to do that? This would exclude ALL fields that are `null`. In the case where there's some malformed input we may not include it in the spec at all (not visible to the user). I'd prefer to reserve this for fields which make sense to be nullable, and nullable fields tend to bloat the config specs.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "jtuglu1 (via GitHub)" <gi...@apache.org>.
jtuglu1 commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2328457981


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -212,6 +218,15 @@ public AggregateFunction getLagAggregate()
     return lagAggregate;
   }
 
+  @Override
+  @JsonProperty
+  @Nullable
+  @JsonInclude(JsonInclude.Include.NON_NULL)

Review Comment:
   > I don't quite follow. A non-nullable field would never be null anyway.
   Of course. I think I was just trying to point out that we should have a standard for leaving null (but optional) fields in a config, versus keeping them out.
   > For anyone reading the json, it doesn't make a real difference if the field is absent or if it is assigned "field": null.
   I think it does. I believe what Gian was implying was that for non-required fields, having null values in the config looks weird/adds bloat.



##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -212,6 +218,15 @@ public AggregateFunction getLagAggregate()
     return lagAggregate;
   }
 
+  @Override
+  @JsonProperty
+  @Nullable
+  @JsonInclude(JsonInclude.Include.NON_NULL)

Review Comment:
   > I don't quite follow. A non-nullable field would never be null anyway.
   
   Of course. I think I was just trying to point out that we should have a standard for leaving null (but optional) fields in a config, versus keeping them out.
   
   > For anyone reading the json, it doesn't make a real difference if the field is absent or if it is assigned "field": null.
   
   I think it does. I believe what Gian was implying was that for non-required fields, having null values in the config looks weird/adds bloat.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "maytasm (via GitHub)" <gi...@apache.org>.
maytasm commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2329077025


##########
docs/ingestion/supervisor.md:
##########
@@ -80,6 +80,7 @@ The following table outlines the configuration properties for `autoScalerConfig`
 |`taskCountStart`|Optional config to specify the number of ingestion tasks to start with. When you enable the autoscaler, Druid ignores the value of `taskCount` in `ioConfig` and, if specified, starts with the `taskCountStart` number of tasks. Otherwise, defaults to `taskCountMin`.|No|`taskCountMin`|
 |`minTriggerScaleActionFrequencyMillis`|The minimum time interval between two scale actions.| No|600000|
 |`autoScalerStrategy`|The algorithm of autoscaler. Druid only supports the `lagBased` strategy. See [Autoscaler strategy](#autoscaler-strategy) for more information.|No|`lagBased`|
+|`stopTaskCountRatio`|A variable version of `ioConfig.stopTaskCount` with a valid range of (0.0, 1.0]. Allows the maximum number of stoppable tasks in steady state to be proportional to the number of tasks currently running.|No||

Review Comment:
   nit: might worth mentioning that when stopTaskCountRatio is set, it takes precedence over stopTaskCount 



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2328497511


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -212,6 +218,15 @@ public AggregateFunction getLagAggregate()
     return lagAggregate;
   }
 
+  @Override
+  @JsonProperty
+  @Nullable
+  @JsonInclude(JsonInclude.Include.NON_NULL)

Review Comment:
   > Of course. I think I was just trying to point out that we should have a standard for leaving null (but optional) fields in a config, versus keeping them out.
   
   Yeah, that would be nice. I think this could be a config on the object mapper itself.
   
   > I think it does.
   
   Oh, I must be missing something then. The only fields that would have ever have a null value are nullable (i.e. non required) fields. Required fields should always be validated in the constructor or assigned a default value if null. So the serialized JSON will always have a non-null value for required fields. A malformed input should fail during deserializing itself.
   
   That said, it is really fine either way. It is only a style choice. 🙂 
   And it seems that in the entirety of Druid code, this annotation is never used on the class level.
   So we can just stick to that for the time being.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2326393726


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -212,6 +218,15 @@ public AggregateFunction getLagAggregate()
     return lagAggregate;
   }
 
+  @Override
+  @JsonProperty
+  @Nullable
+  @JsonInclude(JsonInclude.Include.NON_NULL)

Review Comment:
   > I'd prefer to reserve this for fields which make sense to be nullable
   
   I don't quite follow. A non-nullable field would never be null anyway.
   The constructor would either assign a default value to it or throw an exception.
   For anyone reading the json, it doesn't make a real difference if the field is absent or if it is assigned `"field": null`.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "jtuglu1 (via GitHub)" <gi...@apache.org>.
jtuglu1 commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2328458319


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -49,6 +50,7 @@ public class LagBasedAutoScalerConfig implements AutoScalerConfig
   private final boolean enableTaskAutoScaler;
   private final long minTriggerScaleActionFrequencyMillis;
   private final AggregateFunction lagAggregate;
+  @Nullable private Double stopTaskCountPercent;

Review Comment:
   > I just meant we should drop the @Nullable from @Nullable private Double stopTaskCountPercent
   
   I personally like to mark these things as `@Nullable` as it makes it clear when working the raw value that the value could be null (not just the accessor method). In that case `startTaskCount` annotation should also be changed. We should have a clear standard on these things so style doesn't differ based on who is reviewing.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2326395289


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -49,6 +50,7 @@ public class LagBasedAutoScalerConfig implements AutoScalerConfig
   private final boolean enableTaskAutoScaler;
   private final long minTriggerScaleActionFrequencyMillis;
   private final AggregateFunction lagAggregate;
+  @Nullable private Double stopTaskCountPercent;

Review Comment:
   Yes, the pattern suggested in that comment makes sense.
   
   I just meant we should drop the `@Nullable` from `@Nullable private Double stopTaskCountPercent`
   since none of the other fields have it and it doesn't serve any real purpose.
   It is important to have `@Nullable` in the public APIs like the getter and the constructor arg.



##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -49,6 +50,7 @@ public class LagBasedAutoScalerConfig implements AutoScalerConfig
   private final boolean enableTaskAutoScaler;
   private final long minTriggerScaleActionFrequencyMillis;
   private final AggregateFunction lagAggregate;
+  @Nullable private Double stopTaskCountPercent;

Review Comment:
   Also, should this field be `final`?



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "jtuglu1 (via GitHub)" <gi...@apache.org>.
jtuglu1 merged PR #18480:
URL: https://github.com/apache/druid/pull/18480


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "jtuglu1 (via GitHub)" <gi...@apache.org>.
jtuglu1 commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2325455228


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -49,6 +50,7 @@ public class LagBasedAutoScalerConfig implements AutoScalerConfig
   private final boolean enableTaskAutoScaler;
   private final long minTriggerScaleActionFrequencyMillis;
   private final AggregateFunction lagAggregate;
+  @Nullable private Double stopTaskCountPercent;

Review Comment:
   I'm following a pattern @gianm had [suggested](https://github.com/apache/druid/pull/17900#discussion_r2047872048) a while back.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "jtuglu1 (via GitHub)" <gi...@apache.org>.
jtuglu1 commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2328458319


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -49,6 +50,7 @@ public class LagBasedAutoScalerConfig implements AutoScalerConfig
   private final boolean enableTaskAutoScaler;
   private final long minTriggerScaleActionFrequencyMillis;
   private final AggregateFunction lagAggregate;
+  @Nullable private Double stopTaskCountPercent;

Review Comment:
   > I just meant we should drop the @Nullable from @Nullable private Double stopTaskCountPercent
   
   I personally like to mark these things as `@Nullable` as it makes it clear when working the raw value that the value could be null (not just the accessor method). In that case `startTaskCount` annotation should also be changed. We should have a clear standard on these things (like [this](https://google.github.io/styleguide/javaguide.html) so style doesn't differ based on who is reviewing.



##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -49,6 +50,7 @@ public class LagBasedAutoScalerConfig implements AutoScalerConfig
   private final boolean enableTaskAutoScaler;
   private final long minTriggerScaleActionFrequencyMillis;
   private final AggregateFunction lagAggregate;
+  @Nullable private Double stopTaskCountPercent;

Review Comment:
   > I just meant we should drop the @Nullable from @Nullable private Double stopTaskCountPercent
   
   I personally like to mark these things as `@Nullable` as it makes it clear when working the raw value that the value could be null (not just the accessor method). In that case `startTaskCount` annotation should also be changed. We should have a clear standard on these things (like [this])(https://google.github.io/styleguide/javaguide.html) so style doesn't differ based on who is reviewing.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "jtuglu1 (via GitHub)" <gi...@apache.org>.
jtuglu1 commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2328458319


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -49,6 +50,7 @@ public class LagBasedAutoScalerConfig implements AutoScalerConfig
   private final boolean enableTaskAutoScaler;
   private final long minTriggerScaleActionFrequencyMillis;
   private final AggregateFunction lagAggregate;
+  @Nullable private Double stopTaskCountPercent;

Review Comment:
   > I just meant we should drop the @Nullable from @Nullable private Double stopTaskCountPercent
   
   I personally like to mark these things as `@Nullable` as it makes it clear when working the raw value that the value could be null (not just the accessor method). In that case `startTaskCount` annotation should also be changed. We should have a clear standard on these things (like [this](https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations)) so style doesn't differ based on who is reviewing.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2328495981


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -49,6 +50,7 @@ public class LagBasedAutoScalerConfig implements AutoScalerConfig
   private final boolean enableTaskAutoScaler;
   private final long minTriggerScaleActionFrequencyMillis;
   private final AggregateFunction lagAggregate;
+  @Nullable private Double stopTaskCountPercent;

Review Comment:
   Yeah, that's fair. It would be nice to have a common standard across the codebase.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Add stopTaskCountPercent field to LagBasedAutoscaler (druid)

Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #18480:
URL: https://github.com/apache/druid/pull/18480#discussion_r2324294101


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -212,6 +218,15 @@ public AggregateFunction getLagAggregate()
     return lagAggregate;
   }
 
+  @Override
+  @JsonProperty
+  @Nullable
+  @JsonInclude(JsonInclude.Include.NON_NULL)

Review Comment:
   This can be moved to the class level itself.



##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -100,6 +103,9 @@ public LagBasedAutoScalerConfig(
     this.scaleOutStep = scaleOutStep != null ? scaleOutStep : 2;
     this.minTriggerScaleActionFrequencyMillis = minTriggerScaleActionFrequencyMillis
         != null ? minTriggerScaleActionFrequencyMillis : 600000;
+
+    Preconditions.checkArgument(stopTaskCountPercent == null || (stopTaskCountPercent > 0.0 && stopTaskCountPercent <= 1.0), "0.0 < stopTaskCountPercent <= 1.0");

Review Comment:
   If the value range is [0, 1], we should call the field `stopTaskCountRatio`.
   Alternatively, if we want to keep a percentage in the range [0, 100], we should use an int field instead.



##########
indexing-service/src/test/java/org/apache/druid/indexing/overlord/supervisor/autoscaler/LagBasedAutoScalerConfigTest.java:
##########
@@ -0,0 +1,294 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.indexing.overlord.supervisor.autoscaler;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.druid.indexing.seekablestream.supervisor.autoscaler.LagBasedAutoScalerConfig;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class LagBasedAutoScalerConfigTest

Review Comment:
   Thanks for adding these tests!



##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -49,6 +50,7 @@ public class LagBasedAutoScalerConfig implements AutoScalerConfig
   private final boolean enableTaskAutoScaler;
   private final long minTriggerScaleActionFrequencyMillis;
   private final AggregateFunction lagAggregate;
+  @Nullable private Double stopTaskCountPercent;

Review Comment:
   Nit: I don't think we need to mark this as nullable too. It should be enough to mark just the getter as nullable.



##########
docs/ingestion/supervisor.md:
##########
@@ -80,6 +80,7 @@ The following table outlines the configuration properties for `autoScalerConfig`
 |`taskCountStart`|Optional config to specify the number of ingestion tasks to start with. When you enable the autoscaler, Druid ignores the value of `taskCount` in `ioConfig` and, if specified, starts with the `taskCountStart` number of tasks. Otherwise, defaults to `taskCountMin`.|No|`taskCountMin`|
 |`minTriggerScaleActionFrequencyMillis`|The minimum time interval between two scale actions.| No|600000|
 |`autoScalerStrategy`|The algorithm of autoscaler. Druid only supports the `lagBased` strategy. See [Autoscaler strategy](#autoscaler-strategy) for more information.|No|`lagBased`|
+|`stopTaskCountPercent`|A variable version of `ioConfig.stopTaskCount`. Allows the maximum number of stoppable tasks in steady state to be proportional to the # of tasks running.|No||

Review Comment:
   ```suggestion
   |`stopTaskCountPercent`|A variable version of `ioConfig.stopTaskCount`. Allows the maximum number of stoppable tasks in steady state to be proportional to the number of tasks currently running.|No||
   ```



##########
indexing-service/src/test/java/org/apache/druid/indexing/overlord/supervisor/autoscaler/LagBasedAutoScalerConfigTest.java:
##########
@@ -0,0 +1,294 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.indexing.overlord.supervisor.autoscaler;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.druid.indexing.seekablestream.supervisor.autoscaler.LagBasedAutoScalerConfig;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class LagBasedAutoScalerConfigTest
+{
+  private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+  @Test
+  public void testSerdeWithDefaults() throws Exception
+  {
+    LagBasedAutoScalerConfig config = OBJECT_MAPPER.readValue(
+        OBJECT_MAPPER.writeValueAsString(
+            OBJECT_MAPPER.readValue(
+                "{}",
+                LagBasedAutoScalerConfig.class
+            )

Review Comment:
   Just this part should be enough to verify the default values.
   We need not perform a repeated deserialize-serialize-deserialize.



##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisorStateTest.java:
##########
@@ -2689,6 +2690,55 @@ public Duration getEmissionDuration()
     replayAll();
   }
 
+  @Test
+  public void testMaxAllowedStopsWithStopTaskCountPercent()
+  {
+    LagAggregator lagAggregator = createMock(LagAggregator.class);
+    AutoScalerConfig autoScalerConfig = new LagBasedAutoScalerConfig(

Review Comment:
   Looking at the various test cases, I think it might make sense to add a `Builder` for the `LagBasedAutoScalerConfig` class. Not a blocker for this PR, though.



##########
indexing-service/src/test/java/org/apache/druid/indexing/overlord/supervisor/autoscaler/LagBasedAutoScalerConfigTest.java:
##########
@@ -0,0 +1,294 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.indexing.overlord.supervisor.autoscaler;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.druid.indexing.seekablestream.supervisor.autoscaler.LagBasedAutoScalerConfig;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class LagBasedAutoScalerConfigTest
+{
+  private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+  @Test
+  public void testSerdeWithDefaults() throws Exception
+  {
+    LagBasedAutoScalerConfig config = OBJECT_MAPPER.readValue(
+        OBJECT_MAPPER.writeValueAsString(
+            OBJECT_MAPPER.readValue(
+                "{}",
+                LagBasedAutoScalerConfig.class
+            )

Review Comment:
   We can have one separate test which verifies that the object obtained on serialize and then deserialize is the same as the original.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org