You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "adithyachakilam (via GitHub)" <gi...@apache.org> on 2024/04/25 18:27:03 UTC
[PR] Make #16284 backward compatible (druid)
adithyachakilam opened a new pull request, #16334:
URL: https://github.com/apache/druid/pull/16334
In #16284, we changed the way how kinesis autoscaler computes the lag for the purposes of autoscaling. Put that feature behind a flag so as to not annoy customers who have already configured the auto scaler thesholds based on the total lag.
This PR has:
- [x] 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.
- [x] 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.
- [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.
- [ ] 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] Make #16284 backward compatible (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #16334:
URL: https://github.com/apache/druid/pull/16334#discussion_r1580415217
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -61,7 +62,8 @@ public LagBasedAutoScalerConfig(
@Nullable @JsonProperty("scaleInStep") Integer scaleInStep,
@Nullable @JsonProperty("scaleOutStep") Integer scaleOutStep,
@Nullable @JsonProperty("enableTaskAutoScaler") Boolean enableTaskAutoScaler,
- @Nullable @JsonProperty("minTriggerScaleActionFrequencyMillis") Long minTriggerScaleActionFrequencyMillis
+ @Nullable @JsonProperty("minTriggerScaleActionFrequencyMillis") Long minTriggerScaleActionFrequencyMillis,
+ @Nullable @JsonProperty("useDefaultTotalLag") Boolean useDefaultTotalLag
Review Comment:
I agree that the name should be `lagStatsType` or if you just want to use max, then `useMaxLag`. I don't mind it being an enum, my only concern is that it is limiting. What do we do if we want something outside of total/max/avg?
The approach in this PR is not exactly the same as the original PR, because here we drive the decision by a config and not a method on the `Supervisor` itself.
I would prefer it we could make the following changes in this PR:
1. If we intend to drive the decision via a config, then let's get rid of the method `computeLagForAutoScaler()` altogether.
2. Add a new field `preferredScalingMetric` to `LagStats` (returned by `computeLagStats()`). This field can take the same enum values as the new config. For now, this value will be `TOTAL` for both Kinesis and Kafka. After we have done some validation, the `KinesisSupervisor.computeLagStats()` would return a `LagStats` with `preferredScalingMetric = MAX`.
3. The `LagBasedAutoScaler` will ultimately decide which metric to use. The new config will essentially override the `preferredScalingMetric`. If the config is not specified, we use the `preferredScalingMetric` returned by the `computeLagStats` method.
4. Have a plan on how we will eventually get rid of the new config or atleast compute its default value better, because a single default value of this config is not going to work for all kinds of supervisors. We wouldn't want users to have to specify this config in every supervisor spec. I think step 2 above will help with this.
---
My concerns with the original approach were:
1. It was computing the lag in a roundabout manner. Supervisor needed to expose two methods `computeLagStats` and `getLagMetric`. Then the auto-scaler had to use the result of these two methods to determine the actual lag. If it is the Supervisor which drives this computation, the Supervisor might as well have a single method that returns the required lag value.
2. Enum is limited to TOTAL, MAX, AVG. Having a separate method for `computeLagForAutoScaler` allows us to keep the implementation more flexible. I don't know when we would need a value outside of total / max / avg though, perhaps if we wanted a normalized / truncated value of one of these metrics.
3. I didn't fully like the idea of adding a new method `computeLagForAutoScaler` either because the method `computeLagStats` itself was meant only to be used by the auto-scaler. Why have one more method? I suggested that approach as I didn't have a better alternative at that time which could move things along faster.
--
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] Make #16284 backward compatible (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz merged PR #16334:
URL: https://github.com/apache/druid/pull/16334
--
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] Make #16284 backward compatible (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #16334:
URL: https://github.com/apache/druid/pull/16334#discussion_r1581717506
##########
docs/ingestion/supervisor.md:
##########
@@ -96,6 +96,7 @@ The following table outlines the configuration properties related to the `lagBas
|`scaleActionPeriodMillis`|The frequency in milliseconds to check if a scale action is triggered.|No|60000|
|`scaleInStep`|The number of tasks to reduce at once when scaling down.|No|1|
|`scaleOutStep`|The number of tasks to add at once when scaling out.|No|2|
+|`lagStatsType`|The stat ("MAX"/"TOTAL"/"AVG") to choose from the partitions lag for scaling decisions|No|Default provided by the supervisor|
Review Comment:
Currently the default value is SUM for all supervisors. We can update the docs when we have different defaults for different supervisors.
```suggestion
|`lagAggregate`|The aggregate function used to compute the lag metric for scaling decisions. Possible values are `MAX`, `SUM` and `AVERAGE`. |No|`SUM`|
```
##########
server/src/main/java/org/apache/druid/indexing/overlord/supervisor/autoscaler/ScalingMetric.java:
##########
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+public enum ScalingMetric
+{
+ MAX,
+ TOTAL,
Review Comment:
```suggestion
SUM,
```
##########
server/src/main/java/org/apache/druid/indexing/overlord/supervisor/autoscaler/ScalingMetric.java:
##########
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+public enum ScalingMetric
Review Comment:
I think a better name would be `AggregateFunction`.
##########
server/src/main/java/org/apache/druid/indexing/overlord/supervisor/autoscaler/LagStats.java:
##########
@@ -46,4 +53,22 @@ public long getAvgLag()
{
return avgLag;
}
+
+ public long getPrefferedScalingMetric()
Review Comment:
Typo. This method should return the `ScalingMetric` object itself.
```suggestion
public ScalingMetric getPreferredScalingMetric()
```
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -61,7 +63,8 @@ public LagBasedAutoScalerConfig(
@Nullable @JsonProperty("scaleInStep") Integer scaleInStep,
@Nullable @JsonProperty("scaleOutStep") Integer scaleOutStep,
@Nullable @JsonProperty("enableTaskAutoScaler") Boolean enableTaskAutoScaler,
- @Nullable @JsonProperty("minTriggerScaleActionFrequencyMillis") Long minTriggerScaleActionFrequencyMillis
+ @Nullable @JsonProperty("minTriggerScaleActionFrequencyMillis") Long minTriggerScaleActionFrequencyMillis,
+ @Nullable @JsonProperty("lagStatsType") ScalingMetric lagStatsType
Review Comment:
Suggestion for rename:
```suggestion
@Nullable @JsonProperty("lagAggregate") AggregateFunction lagAggregate
```
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScaler.java:
##########
@@ -154,8 +155,15 @@ private Runnable computeAndCollectLag()
LOCK.lock();
try {
if (!spec.isSuspended()) {
- long lag = supervisor.computeLagForAutoScaler();
- lagMetricsQueue.offer(lag > 0 ? lag : 0L);
+ LagStats lagStats = supervisor.computeLagStats();
+ if (lagStats != null) {
+ long lag = lagBasedAutoScalerConfig.getLagStatsType() != null ?
+ lagStats.getMetric(lagBasedAutoScalerConfig.getLagStatsType()) :
+ lagStats.getPrefferedScalingMetric();
Review Comment:
```suggestion
final ScalingMetric scalingMetric = lagBasedAutoScalerConfig.getLagStatsType() == null
? lagStats.getPreferredScalingMetric()
: lagBasedAutoScalerConfig.getLagStatsType() == null;
long lag = lagStats.getMetric(scalingMetric);
```
##########
server/src/main/java/org/apache/druid/indexing/overlord/supervisor/autoscaler/LagStats.java:
##########
@@ -24,12 +24,19 @@ public class LagStats
private final long maxLag;
private final long totalLag;
private final long avgLag;
+ private final ScalingMetric preferredScalingMetric;
Review Comment:
Nit: Thinking about the name again, we could call this field `preferredAggregateForScaling` or even simply `aggregateForScaling`.
##########
server/src/main/java/org/apache/druid/indexing/overlord/supervisor/autoscaler/LagStats.java:
##########
@@ -24,12 +24,19 @@ public class LagStats
private final long maxLag;
private final long totalLag;
private final long avgLag;
+ private final ScalingMetric preferredScalingMetric;
public LagStats(long maxLag, long totalLag, long avgLag)
+ {
+ this(maxLag, totalLag, avgLag, ScalingMetric.TOTAL);
+ }
+
+ public LagStats(long maxLag, long totalLag, long avgLag, ScalingMetric preferredScalingMetric)
{
this.maxLag = maxLag;
this.totalLag = totalLag;
this.avgLag = avgLag;
+ this.preferredScalingMetric = preferredScalingMetric;
Review Comment:
We should assign it a default value of `SUM` if the passed argument is 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] Make #16284 backward compatible (druid)
Posted by "adithyachakilam (via GitHub)" <gi...@apache.org>.
adithyachakilam commented on code in PR #16334:
URL: https://github.com/apache/druid/pull/16334#discussion_r1582147841
##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/SeekableStreamSupervisorSpecTest.java:
##########
@@ -988,7 +1007,8 @@ public void testSeekableStreamSupervisorSpecWithScaleIn() throws InterruptedExce
Thread.sleep(1000);
int taskCountAfterScaleOut = supervisor.getIoConfig().getTaskCount();
Assert.assertEquals(1, taskCountAfterScaleOut);
-
+ Assert.assertTrue(timesLagStatsMaxCalled == 0);
+ Assert.assertTrue(timesLagStatsSumCalled > 0);
Review Comment:
I think that test is already there now. This test verifies the override by the config is working fine.
--
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] Make #16284 backward compatible (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #16334:
URL: https://github.com/apache/druid/pull/16334#discussion_r1580415217
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -61,7 +62,8 @@ public LagBasedAutoScalerConfig(
@Nullable @JsonProperty("scaleInStep") Integer scaleInStep,
@Nullable @JsonProperty("scaleOutStep") Integer scaleOutStep,
@Nullable @JsonProperty("enableTaskAutoScaler") Boolean enableTaskAutoScaler,
- @Nullable @JsonProperty("minTriggerScaleActionFrequencyMillis") Long minTriggerScaleActionFrequencyMillis
+ @Nullable @JsonProperty("minTriggerScaleActionFrequencyMillis") Long minTriggerScaleActionFrequencyMillis,
+ @Nullable @JsonProperty("useDefaultTotalLag") Boolean useDefaultTotalLag
Review Comment:
I agree that the name should be `lagStatsType` or if you just want to use max, then `useMaxLag`. I don't mind it being an enum, my only concern is that it is limiting. What do we do if we want something outside of total/max/avg?
The approach in this PR is not exactly the same as the original PR, because here we drive the decision by a config and not a method on the `Supervisor` itself.
I would prefer it we could make the following changes in this PR:
1. If we intend to drive the decision via a config, let's get rid of the method `computeLagForAutoScaler()` altogether.
2. Update `LagStats` (returned by `computeLagStats()`) to have a field `preferredScalingMetric` which would be the new enum we add. For now, this value will be `TOTAL` for both Kinesis and Kafka. After we have done some validation, the `KinesisSupervisor.computeLagStats()` would return a `LagStats` with `preferredScalingMetric` as `MAX` for Kinesis.
3. The new config will essentially override the `preferredScalingMetric`. If the config is not specified, we use the `preferredScalingMetric` returned by the `computeLagStats` method. This logic should be in the `LagBasedAutoScaler` itself.
4. Let's have a plan on how we will eventually get rid of the new config or atleast compute its default value better. Because a single default value of this config is not going to work for all kinds of supervisors. We wouldn't want users to have to specify this config in every supervisor spec. I think step 2 above will help with this.
---
My concerns with the original approach were:
1. It was computing the lag in a roundabout manner. Supervisor needed to expose two methods `computeLagStats` and `getLagMetric`. Then the auto-scaler had to use the result of these two methods to determine the actual lag. If it is the Supervisor which drives this computation, the Supervisor might as well have a single method that returns the required lag value.
2. Enum is limited to TOTAL, MAX, AVG. Having a separate method for `computeLagForAutoScaler` allows us to keep the implementation more flexible. I don't know when we would need a value outside of total / max / avg though, perhaps if we wanted a normalized / truncated value of one of these metrics.
3. I didn't fully like the idea of adding a new method `computeLagForAutoScaler` either because the method `computeLagStats` itself was meant only to be used by the auto-scaler. Why have one more method? I suggested that approach as I didn't have a better alternative at that time which could move things along faster.
--
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] Make #16284 backward compatible (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #16334:
URL: https://github.com/apache/druid/pull/16334#discussion_r1582071140
##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/SeekableStreamSupervisorSpecTest.java:
##########
@@ -131,8 +135,21 @@ public void setUp()
monitorSchedulerConfig = EasyMock.mock(DruidMonitorSchedulerConfig.class);
supervisorStateManagerConfig = EasyMock.mock(SupervisorStateManagerConfig.class);
supervisor4 = EasyMock.mock(SeekableStreamSupervisor.class);
+ lagStats = EasyMock.mock(LagStats.class);
+ timesLagStatsMaxCalled = 0;
+ timesLagStatsSumCalled = 0;
EasyMock.expect(spec.getContextValue(DruidMetrics.TAGS)).andReturn(null).anyTimes();
+ EasyMock.expect(lagStats.getAggregateForScaling()).andReturn(AggregateFunction.SUM).anyTimes();
+ EasyMock.expect(lagStats.getMetric(AggregateFunction.SUM)).andAnswer(() -> {
+ timesLagStatsSumCalled++;
+ return 0L;
+ }).anyTimes();
+ EasyMock.expect(lagStats.getMetric(AggregateFunction.MAX)).andAnswer(() -> {
+ timesLagStatsMaxCalled++;
+ return 0L;
+ }).anyTimes();
+ EasyMock.replay(lagStats);
Review Comment:
These are weird expectations. Why do we care how many times sum and max were called?
##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/SeekableStreamSupervisorSpecTest.java:
##########
@@ -131,8 +135,21 @@ public void setUp()
monitorSchedulerConfig = EasyMock.mock(DruidMonitorSchedulerConfig.class);
supervisorStateManagerConfig = EasyMock.mock(SupervisorStateManagerConfig.class);
supervisor4 = EasyMock.mock(SeekableStreamSupervisor.class);
+ lagStats = EasyMock.mock(LagStats.class);
Review Comment:
`LagStats` is a simple POJO. We shouldn't have to mock it.
##########
server/src/main/java/org/apache/druid/indexing/overlord/supervisor/autoscaler/LagStats.java:
##########
@@ -58,6 +60,7 @@ public long getAvgLag()
* The preferred scaling metric that supervisor may specify to be used.
* This could be overrided by the autscaler.
*/
+ @Nullable
Review Comment:
This is not nullable (see constructor of this class). `LagStatsAutoScalerConfig.getLagAggregate()` is nullable.
##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/SeekableStreamSupervisorSpecTest.java:
##########
@@ -988,7 +1007,8 @@ public void testSeekableStreamSupervisorSpecWithScaleIn() throws InterruptedExce
Thread.sleep(1000);
int taskCountAfterScaleOut = supervisor.getIoConfig().getTaskCount();
Assert.assertEquals(1, taskCountAfterScaleOut);
-
+ Assert.assertTrue(timesLagStatsMaxCalled == 0);
+ Assert.assertTrue(timesLagStatsSumCalled > 0);
Review Comment:
Instead of these assertions, we just need a test in `LagStatsTest` that verifies the results of the method `LagStats.getMetric()`.
--
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] Make #16284 backward compatible (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #16334:
URL: https://github.com/apache/druid/pull/16334#discussion_r1581995450
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScaler.java:
##########
@@ -154,8 +156,17 @@ private Runnable computeAndCollectLag()
LOCK.lock();
try {
if (!spec.isSuspended()) {
- long lag = supervisor.computeLagForAutoScaler();
- lagMetricsQueue.offer(lag > 0 ? lag : 0L);
+ LagStats lagStats = supervisor.computeLagStats();
+
+ if (lagStats != null) {
+ AggregateFunction aggregate = lagBasedAutoScalerConfig.getLagAggregate() == null ?
Review Comment:
Looking at the constructor of `LagBasedAutoScalerConfig`, it seems that `getLagAggregate()` will never return null. So, we will never use lagStats.getAggregateForScaling().
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -186,6 +190,12 @@ public long getMinTriggerScaleActionFrequencyMillis()
return minTriggerScaleActionFrequencyMillis;
}
+ @JsonProperty
+ public AggregateFunction getLagAggregate()
Review Comment:
This should be `@Nullable`.
##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/SeekableStreamSupervisorSpecTest.java:
##########
@@ -1336,6 +1336,7 @@ private static Map<String, Object> getScaleOutProperties(int maxTaskCount)
autoScalerConfig.put("scaleInStep", 1);
autoScalerConfig.put("scaleOutStep", 2);
autoScalerConfig.put("minTriggerScaleActionFrequencyMillis", 1200000);
+ autoScalerConfig.put("lagStatsType", "MAX");
Review Comment:
Parameter name needs to be fixed. Also, are we just putting this value or also verifying its effect somewhere?
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -73,6 +76,7 @@ public LagBasedAutoScalerConfig(
this.scaleInThreshold = scaleInThreshold != null ? scaleInThreshold : 1000000;
this.triggerScaleOutFractionThreshold = triggerScaleOutFractionThreshold != null ? triggerScaleOutFractionThreshold : 0.3;
this.triggerScaleInFractionThreshold = triggerScaleInFractionThreshold != null ? triggerScaleInFractionThreshold : 0.9;
+ this.lagAggregate = lagAggregate != null ? lagAggregate : AggregateFunction.SUM;
Review Comment:
We should probably not assign a default value here. Otherwise, we will never get to use the `LagStats.getAggregateForScaling()` as specified by each individual supervisor.
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -204,6 +214,7 @@ public String toString()
", scaleActionPeriodMillis=" + scaleActionPeriodMillis +
", scaleInStep=" + scaleInStep +
", scaleOutStep=" + scaleOutStep +
+ ", lagAggregate=" + lagAggregate +
Review Comment:
indentation seems a little off.
##########
server/src/main/java/org/apache/druid/indexing/overlord/supervisor/autoscaler/AggregateFunction.java:
##########
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+public enum AggregateFunction
+{
+ MAX,
+ SUM,
+ AVG
Review Comment:
Using the same name as mentioned in the docs:
```suggestion
AVERAGE
```
--
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] Make #16284 backward compatible (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #16334:
URL: https://github.com/apache/druid/pull/16334#discussion_r1582204502
##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/SeekableStreamSupervisorSpecTest.java:
##########
@@ -988,7 +1007,8 @@ public void testSeekableStreamSupervisorSpecWithScaleIn() throws InterruptedExce
Thread.sleep(1000);
int taskCountAfterScaleOut = supervisor.getIoConfig().getTaskCount();
Assert.assertEquals(1, taskCountAfterScaleOut);
-
+ Assert.assertTrue(timesLagStatsMaxCalled == 0);
+ Assert.assertTrue(timesLagStatsSumCalled > 0);
Review Comment:
> This test verifies the override by the config is working fine.
The correct way to verify that would be to have different `LagAutoScalerConfig`s and different supervisor impls (which return different values of `LagStats.aggregateForScaling`) and verify that the value of `taskCountAfterScaleOut` changes based on whether the config/supervisor uses MAX or SUM or AVERAGE.
(These tests can also be added later and need not block this PR, unless required for code coverage).
We should not have to mock or spy the `LagStats` class just to check which method was invoked on it. For this test class, the end result is the task scale out and that is all we need to verify. We cannot verify every internal method called when invoking any public interface.
Please revert these test changes, rest of the PR looks okay to me.
--
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] Make #16284 backward compatible (druid)
Posted by "adithyachakilam (via GitHub)" <gi...@apache.org>.
adithyachakilam commented on code in PR #16334:
URL: https://github.com/apache/druid/pull/16334#discussion_r1582148036
##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/SeekableStreamSupervisorSpecTest.java:
##########
@@ -131,8 +135,21 @@ public void setUp()
monitorSchedulerConfig = EasyMock.mock(DruidMonitorSchedulerConfig.class);
supervisorStateManagerConfig = EasyMock.mock(SupervisorStateManagerConfig.class);
supervisor4 = EasyMock.mock(SeekableStreamSupervisor.class);
+ lagStats = EasyMock.mock(LagStats.class);
Review Comment:
I need to spy that class so as to confirm that the config override is working and not calling SUM when MAX is specified and viceversa.
--
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] Make #16284 backward compatible (druid)
Posted by "adithyachakilam (via GitHub)" <gi...@apache.org>.
adithyachakilam commented on code in PR #16334:
URL: https://github.com/apache/druid/pull/16334#discussion_r1582147884
##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/SeekableStreamSupervisorSpecTest.java:
##########
@@ -131,8 +135,21 @@ public void setUp()
monitorSchedulerConfig = EasyMock.mock(DruidMonitorSchedulerConfig.class);
supervisorStateManagerConfig = EasyMock.mock(SupervisorStateManagerConfig.class);
supervisor4 = EasyMock.mock(SeekableStreamSupervisor.class);
+ lagStats = EasyMock.mock(LagStats.class);
+ timesLagStatsMaxCalled = 0;
+ timesLagStatsSumCalled = 0;
EasyMock.expect(spec.getContextValue(DruidMetrics.TAGS)).andReturn(null).anyTimes();
+ EasyMock.expect(lagStats.getAggregateForScaling()).andReturn(AggregateFunction.SUM).anyTimes();
+ EasyMock.expect(lagStats.getMetric(AggregateFunction.SUM)).andAnswer(() -> {
+ timesLagStatsSumCalled++;
+ return 0L;
+ }).anyTimes();
+ EasyMock.expect(lagStats.getMetric(AggregateFunction.MAX)).andAnswer(() -> {
+ timesLagStatsMaxCalled++;
+ return 0L;
+ }).anyTimes();
+ EasyMock.replay(lagStats);
Review Comment:
We can change to Boolean instead of int representing if that method is called or not.
--
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] Make #16284 backward compatible (druid)
Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #16334:
URL: https://github.com/apache/druid/pull/16334#discussion_r1581344718
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScaler.java:
##########
@@ -154,8 +155,15 @@
LOCK.lock();
try {
if (!spec.isSuspended()) {
- long lag = supervisor.computeLagForAutoScaler();
- lagMetricsQueue.offer(lag > 0 ? lag : 0L);
+ LagStats lagStats = supervisor.computeLagStats();
+ if (lagStats != null) {
+ long lag = lagBasedAutoScalerConfig.getLagStatsType() != null ?
+ lagStats.getMetric(lagBasedAutoScalerConfig.getLagStatsType()) :
+ lagStats.getPrefferedScalingMetric();
+ lagMetricsQueue.offer(lag > 0 ? lag : 0L);
+ } else {
+ lagMetricsQueue.offer(0L);
Review Comment:
## Ignored error status of call
Method run ignores exceptional return value of CircularFifoQueue<Long>.offer.
[Show more details](https://github.com/apache/druid/security/code-scanning/7317)
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScaler.java:
##########
@@ -154,8 +155,15 @@
LOCK.lock();
try {
if (!spec.isSuspended()) {
- long lag = supervisor.computeLagForAutoScaler();
- lagMetricsQueue.offer(lag > 0 ? lag : 0L);
+ LagStats lagStats = supervisor.computeLagStats();
+ if (lagStats != null) {
+ long lag = lagBasedAutoScalerConfig.getLagStatsType() != null ?
+ lagStats.getMetric(lagBasedAutoScalerConfig.getLagStatsType()) :
+ lagStats.getPrefferedScalingMetric();
+ lagMetricsQueue.offer(lag > 0 ? lag : 0L);
Review Comment:
## Ignored error status of call
Method run ignores exceptional return value of CircularFifoQueue<Long>.offer.
[Show more details](https://github.com/apache/druid/security/code-scanning/7316)
--
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] Make #16284 backward compatible (druid)
Posted by "suneet-s (via GitHub)" <gi...@apache.org>.
suneet-s commented on code in PR #16334:
URL: https://github.com/apache/druid/pull/16334#discussion_r1581447364
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -61,7 +62,8 @@ public LagBasedAutoScalerConfig(
@Nullable @JsonProperty("scaleInStep") Integer scaleInStep,
@Nullable @JsonProperty("scaleOutStep") Integer scaleOutStep,
@Nullable @JsonProperty("enableTaskAutoScaler") Boolean enableTaskAutoScaler,
- @Nullable @JsonProperty("minTriggerScaleActionFrequencyMillis") Long minTriggerScaleActionFrequencyMillis
+ @Nullable @JsonProperty("minTriggerScaleActionFrequencyMillis") Long minTriggerScaleActionFrequencyMillis,
+ @Nullable @JsonProperty("useDefaultTotalLag") Boolean useDefaultTotalLag
Review Comment:
@kfaraz Cool, makes sense to me.
--
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] Make #16284 backward compatible (druid)
Posted by "suneet-s (via GitHub)" <gi...@apache.org>.
suneet-s commented on code in PR #16334:
URL: https://github.com/apache/druid/pull/16334#discussion_r1580183635
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/LagBasedAutoScalerConfig.java:
##########
@@ -61,7 +62,8 @@ public LagBasedAutoScalerConfig(
@Nullable @JsonProperty("scaleInStep") Integer scaleInStep,
@Nullable @JsonProperty("scaleOutStep") Integer scaleOutStep,
@Nullable @JsonProperty("enableTaskAutoScaler") Boolean enableTaskAutoScaler,
- @Nullable @JsonProperty("minTriggerScaleActionFrequencyMillis") Long minTriggerScaleActionFrequencyMillis
+ @Nullable @JsonProperty("minTriggerScaleActionFrequencyMillis") Long minTriggerScaleActionFrequencyMillis,
+ @Nullable @JsonProperty("useDefaultTotalLag") Boolean useDefaultTotalLag
Review Comment:
I think it would be better to have this be an enum, like what was done in the initial patch. Then the docs for this field would tell the user to set this to one of `TOTAL`, `MAX` or `AVG` with the default implementation using the total lag.
@kfaraz do you have any concerns with this approach since you had some comments about the use of an enum in an earlier patch.
On naming - I think the name could be something like `lagStatsType` The word `default` in the current name is confusing to me. Once there is agreement on the approach, there should also be a doc update in the `supervisor.md` page for this new config option.
--
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] Make #16284 backward compatible (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #16334:
URL: https://github.com/apache/druid/pull/16334#discussion_r1582204068
##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/SeekableStreamSupervisorSpecTest.java:
##########
@@ -988,7 +1007,8 @@ public void testSeekableStreamSupervisorSpecWithScaleIn() throws InterruptedExce
Thread.sleep(1000);
int taskCountAfterScaleOut = supervisor.getIoConfig().getTaskCount();
Assert.assertEquals(1, taskCountAfterScaleOut);
-
+ Assert.assertTrue(timesLagStatsMaxCalled == 0);
+ Assert.assertTrue(timesLagStatsSumCalled > 0);
Review Comment:
> I think that test is already there now.
Thanks, I must have missed that.
##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/SeekableStreamSupervisorSpecTest.java:
##########
@@ -988,7 +1007,8 @@ public void testSeekableStreamSupervisorSpecWithScaleIn() throws InterruptedExce
Thread.sleep(1000);
int taskCountAfterScaleOut = supervisor.getIoConfig().getTaskCount();
Assert.assertEquals(1, taskCountAfterScaleOut);
-
+ Assert.assertTrue(timesLagStatsMaxCalled == 0);
+ Assert.assertTrue(timesLagStatsSumCalled > 0);
Review Comment:
> I think that test is already there now.
Thanks, I must have missed that.
--
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] Make #16284 backward compatible (druid)
Posted by "suneet-s (via GitHub)" <gi...@apache.org>.
suneet-s commented on PR #16334:
URL: https://github.com/apache/druid/pull/16334#issuecomment-2083212759
@adithyachakilam Can you please backport this change to the 30.0 branch as it looks like #16284 is in that branch
--
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] Make #16284 backward compatible (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on PR #16334:
URL: https://github.com/apache/druid/pull/16334#issuecomment-2083206403
Merging this PR as the pending tests are stuck due to the issue described in #16347 . The same tests have already passed on a different JDK.
--
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] Make #16284 backward compatible (druid)
Posted by "adithyachakilam (via GitHub)" <gi...@apache.org>.
adithyachakilam commented on code in PR #16334:
URL: https://github.com/apache/druid/pull/16334#discussion_r1582011192
##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/SeekableStreamSupervisorSpecTest.java:
##########
@@ -1336,6 +1336,7 @@ private static Map<String, Object> getScaleOutProperties(int maxTaskCount)
autoScalerConfig.put("scaleInStep", 1);
autoScalerConfig.put("scaleOutStep", 2);
autoScalerConfig.put("minTriggerScaleActionFrequencyMillis", 1200000);
+ autoScalerConfig.put("lagStatsType", "MAX");
Review Comment:
added verifications.
--
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] Make #16284 backward compatible (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #16334:
URL: https://github.com/apache/druid/pull/16334#discussion_r1581717796
##########
server/src/main/java/org/apache/druid/indexing/overlord/supervisor/autoscaler/LagStats.java:
##########
@@ -46,4 +53,22 @@ public long getAvgLag()
{
return avgLag;
}
+
+ public long getPrefferedScalingMetric()
Review Comment:
Typo. This method should return the `AggregateFunction` object itself. Please add a javadoc to this method too.
```suggestion
public AggregateFunction getAggregateForScaling()
```
##########
server/src/main/java/org/apache/druid/indexing/overlord/supervisor/autoscaler/LagStats.java:
##########
@@ -46,4 +53,22 @@ public long getAvgLag()
{
return avgLag;
}
+
+ public long getPrefferedScalingMetric()
Review Comment:
This method should return the `AggregateFunction` object itself. Please add a javadoc to this method too.
```suggestion
public AggregateFunction getAggregateForScaling()
```
--
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