-
Notifications
You must be signed in to change notification settings - Fork 3.8k
minor: Fix metric values of costBased auto-scaler #19641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,6 @@ | |
| import org.apache.druid.indexing.overlord.supervisor.SupervisorSpec; | ||
| import org.apache.druid.indexing.overlord.supervisor.autoscaler.SupervisorTaskAutoScaler; | ||
| import org.apache.druid.indexing.seekablestream.supervisor.SeekableStreamSupervisor; | ||
| import org.apache.druid.java.util.emitter.EmittingLogger; | ||
| import org.apache.druid.java.util.emitter.service.ServiceEmitter; | ||
| import org.joda.time.Duration; | ||
|
|
||
|
|
@@ -45,18 +44,15 @@ | |
| @JsonInclude(JsonInclude.Include.NON_NULL) | ||
| public class CostBasedAutoScalerConfig implements AutoScalerConfig | ||
| { | ||
| private static final EmittingLogger LOG = new EmittingLogger(CostBasedAutoScalerConfig.class); | ||
|
|
||
| static final long DEFAULT_SCALE_ACTION_PERIOD_MILLIS = 10 * 60 * 1000; // 10 minutes | ||
| static final double DEFAULT_LAG_WEIGHT = 0.4; | ||
| static final double DEFAULT_IDLE_WEIGHT = 0.6; | ||
| static final Duration DEFAULT_MIN_SCALE_DELAY = Duration.millis(DEFAULT_SCALE_ACTION_PERIOD_MILLIS * 3); | ||
| static final Duration DEFAULT_MIN_SCALE_UP_DELAY = Duration.standardMinutes(10); | ||
| static final Duration DEFAULT_MIN_SCALE_DOWN_DELAY = Duration.standardMinutes(30); | ||
|
|
||
| private final boolean enableTaskAutoScaler; | ||
| private final int taskCountMax; | ||
| private final int taskCountMin; | ||
| private final Integer taskCountStart; | ||
| private final long minTriggerScaleActionFrequencyMillis; | ||
| private final Double stopTaskCountRatio; | ||
| private final long scaleActionPeriodMillis; | ||
|
|
||
|
|
@@ -72,17 +68,13 @@ public class CostBasedAutoScalerConfig implements AutoScalerConfig | |
|
|
||
| /** | ||
| * Creates a new CostBasedAutoScalerConfig instance. | ||
| * <p> | ||
| * Note: useTaskCountBoundaries and highLagThreshold are kept for backward compatibility, | ||
| * but effectively they are removed. | ||
| */ | ||
| @JsonCreator | ||
| public CostBasedAutoScalerConfig( | ||
| @JsonProperty("taskCountMax") Integer taskCountMax, | ||
| @JsonProperty("taskCountMin") Integer taskCountMin, | ||
| @Nullable @JsonProperty("enableTaskAutoScaler") Boolean enableTaskAutoScaler, | ||
| @Nullable @JsonProperty("taskCountStart") Integer taskCountStart, | ||
| @Nullable @JsonProperty("minTriggerScaleActionFrequencyMillis") Long minTriggerScaleActionFrequencyMillis, | ||
| @Nullable @JsonProperty("stopTaskCountRatio") Double stopTaskCountRatio, | ||
| @Nullable @JsonProperty("scaleActionPeriodMillis") Long scaleActionPeriodMillis, | ||
| @Nullable @JsonProperty("lagWeight") Double lagWeight, | ||
|
|
@@ -96,18 +88,9 @@ public CostBasedAutoScalerConfig( | |
| @Nullable @JsonProperty("usePollIdleRatio") Boolean usePollIdleRatio | ||
| ) | ||
| { | ||
| this.enableTaskAutoScaler = enableTaskAutoScaler != null ? enableTaskAutoScaler : false; | ||
|
|
||
| // Timing configuration with defaults | ||
| this.scaleActionPeriodMillis = scaleActionPeriodMillis != null | ||
| ? scaleActionPeriodMillis | ||
| : DEFAULT_SCALE_ACTION_PERIOD_MILLIS; | ||
| this.minTriggerScaleActionFrequencyMillis = Configs.valueOrDefault( | ||
| minTriggerScaleActionFrequencyMillis, | ||
| DEFAULT_SCALE_ACTION_PERIOD_MILLIS | ||
| ); | ||
| this.enableTaskAutoScaler = Configs.valueOrDefault(enableTaskAutoScaler, false); | ||
| this.scaleActionPeriodMillis = Configs.valueOrDefault(scaleActionPeriodMillis, DEFAULT_MIN_SCALE_UP_DELAY.getMillis()); | ||
|
|
||
| // Cost function weights with defaults | ||
| this.lagWeight = Configs.valueOrDefault(lagWeight, DEFAULT_LAG_WEIGHT); | ||
| this.idleWeight = Configs.valueOrDefault(idleWeight, DEFAULT_IDLE_WEIGHT); | ||
| this.optimalTaskIdleRatio = Configs.valueOrDefault( | ||
|
|
@@ -116,11 +99,8 @@ public CostBasedAutoScalerConfig( | |
| ); | ||
| this.useTaskCountBoundariesOnScaleUp = Configs.valueOrDefault(useTaskCountBoundariesOnScaleUp, false); | ||
| this.useTaskCountBoundariesOnScaleDown = Configs.valueOrDefault(useTaskCountBoundariesOnScaleDown, true); | ||
| this.minScaleUpDelay = Configs.valueOrDefault( | ||
| minScaleUpDelay, | ||
| Duration.millis(this.minTriggerScaleActionFrequencyMillis) | ||
| ); | ||
| this.minScaleDownDelay = Configs.valueOrDefault(minScaleDownDelay, DEFAULT_MIN_SCALE_DELAY); | ||
| this.minScaleUpDelay = Configs.valueOrDefault(minScaleUpDelay, DEFAULT_MIN_SCALE_UP_DELAY); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Preserve the legacy cooldown fallback Existing cost-based supervisor specs can still contain |
||
| this.minScaleDownDelay = Configs.valueOrDefault(minScaleDownDelay, DEFAULT_MIN_SCALE_DOWN_DELAY); | ||
| this.scaleDownDuringTaskRolloverOnly = Configs.valueOrDefault(scaleDownDuringTaskRolloverOnly, false); | ||
| this.usePollIdleRatio = Configs.valueOrDefault(usePollIdleRatio, true); | ||
|
|
||
|
|
@@ -204,7 +184,7 @@ public Integer getTaskCountStart() | |
| @JsonProperty | ||
| public long getMinTriggerScaleActionFrequencyMillis() | ||
| { | ||
| return minTriggerScaleActionFrequencyMillis; | ||
| return -1; | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -308,7 +288,7 @@ public boolean isUsePollIdleRatio() | |
| @Override | ||
| public SupervisorTaskAutoScaler createAutoScaler(Supervisor supervisor, SupervisorSpec spec, ServiceEmitter emitter) | ||
| { | ||
| return new CostBasedAutoScaler((SeekableStreamSupervisor) supervisor, this, spec, emitter); | ||
| return new CostBasedAutoScaler((SeekableStreamSupervisor<?, ?, ?>) supervisor, this, spec, emitter); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -326,7 +306,6 @@ public boolean equals(Object o) | |
| return enableTaskAutoScaler == that.enableTaskAutoScaler | ||
| && taskCountMax == that.taskCountMax | ||
| && taskCountMin == that.taskCountMin | ||
| && minTriggerScaleActionFrequencyMillis == that.minTriggerScaleActionFrequencyMillis | ||
| && scaleActionPeriodMillis == that.scaleActionPeriodMillis | ||
| && Double.compare(that.lagWeight, lagWeight) == 0 | ||
| && Double.compare(that.idleWeight, idleWeight) == 0 | ||
|
|
@@ -349,7 +328,6 @@ public int hashCode() | |
| taskCountMax, | ||
| taskCountMin, | ||
| taskCountStart, | ||
| minTriggerScaleActionFrequencyMillis, | ||
| stopTaskCountRatio, | ||
| scaleActionPeriodMillis, | ||
| lagWeight, | ||
|
|
@@ -372,7 +350,6 @@ public String toString() | |
| ", taskCountMax=" + taskCountMax + | ||
| ", taskCountMin=" + taskCountMin + | ||
| ", taskCountStart=" + taskCountStart + | ||
| ", minTriggerScaleActionFrequencyMillis=" + minTriggerScaleActionFrequencyMillis + | ||
| ", stopTaskCountRatio=" + stopTaskCountRatio + | ||
| ", scaleActionPeriodMillis=" + scaleActionPeriodMillis + | ||
| ", lagWeight=" + lagWeight + | ||
|
|
@@ -397,7 +374,6 @@ public static class Builder | |
| private Integer taskCountMin; | ||
| private Boolean enableTaskAutoScaler = true; | ||
| private Integer taskCountStart; | ||
| private Long minTriggerScaleActionFrequencyMillis; | ||
| private Double stopTaskCountRatio; | ||
| private Long scaleActionPeriodMillis; | ||
| private Double lagWeight; | ||
|
|
@@ -438,12 +414,6 @@ public Builder taskCountStart(Integer taskCountStart) | |
| return this; | ||
| } | ||
|
|
||
| public Builder minTriggerScaleActionFrequencyMillis(long minTriggerScaleActionFrequencyMillis) | ||
| { | ||
| this.minTriggerScaleActionFrequencyMillis = minTriggerScaleActionFrequencyMillis; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder stopTaskCountRatio(Double stopTaskCountRatio) | ||
| { | ||
| this.stopTaskCountRatio = stopTaskCountRatio; | ||
|
|
@@ -517,7 +487,6 @@ public CostBasedAutoScalerConfig build() | |
| taskCountMin, | ||
| enableTaskAutoScaler, | ||
| taskCountStart, | ||
| minTriggerScaleActionFrequencyMillis, | ||
| stopTaskCountRatio, | ||
| scaleActionPeriodMillis, | ||
| lagWeight, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also would like to request you to emit
estimateIdleRatioFromProcessingRate()as separate metric for better tracking.