Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Execute autoscaler synchronously on scheduler thread #158

Merged
merged 4 commits into from
Aug 14, 2017
Merged

Execute autoscaler synchronously on scheduler thread #158

merged 4 commits into from
Aug 14, 2017

Conversation

corindwyer
Copy link
Contributor

  • change autoscaler to be synchronously executed as part of the scheduling iteration while keeping the callback execution on a separate thread
  • change shortfall analysis implementation to be synchronously executed as part of the autoscaler
  • add withAutoscaleDisabledVmDurationInSecs for users that want to disable VMs for a fixed duration that is different from the cooldown value

…ing iteration while keeping the callback execution on a separate thread

change shortfall analysis implementation to be synchronously executed as part of the autoscaler
add withAutoscaleDisabledVmDurationInSecs for users that want to disable VMs for a fixed duration that is different from the cooldown value
}
}
return () -> {
if (!lock.tryLock())
Copy link

Choose a reason for hiding this comment

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

Release lock?

Copy link
Contributor Author

@corindwyer corindwyer Aug 14, 2017

Choose a reason for hiding this comment

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

Yes, we need to release the lock here. Still need to confirm if this class is responsible for preventing multithreaded calls to the scheduling loop or if it is even supposed to protect the main thread from making multiple calls.

* @see <a href="https://github.com/Netflix/Fenzo/wiki/Autoscaling">Autoscaling</a>
*/
public Builder withAutoscaleDisabledVmDurationInSecs(long disabledVmDurationInSecs) {
if(disabledVmDurationInSecs > 0L)
Copy link

Choose a reason for hiding this comment

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

<= 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

if (values != null && values.length == 2)
ports = Math.max(ports, values[0] + values[1]);
for (AssignableVirtualMachine avm : avms) {
Map<VMResource, Double> maxResources = avm.getMaxResources();
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to confirm if maxResources is set already by the time this is called

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we confirmed this is set because the pseudo scheduling happens after the main scheduling.

StateMonitor() {
lock = new AtomicBoolean(false);
}
private final ReentrantLock lock = new ReentrantLock();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed to be reentrant?

@@ -466,6 +484,9 @@ private TaskScheduler(Builder builder) {
autoScaler.setDelayScaleDownBySecs(builder.delayAutoscaleDownBySecs);
if(builder.delayAutoscaleUpBySecs > 0L)
autoScaler.setDelayScaleUpBySecs(builder.delayAutoscaleUpBySecs);
if (builder.disabledVmDurationInSecs > 0L) {
autoScaler.setDisabledVmDurationInSecs(builder.disabledVmDurationInSecs);
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a risk in this being separate from cooldown secs. For example, the VM maybe enabled too soon and start getting assignments before it is terminated.

Copy link
Contributor Author

@corindwyer corindwyer Aug 14, 2017

Choose a reason for hiding this comment

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

added javadoc to outline that this value should be greater than the cooldown period and is only useful if the autoscaling action may take more time to execute than your cooldown period.

revert StateMonitor to the previous implementation
create a new pseudo scheduling method that ignores the lock
@corindwyer corindwyer merged commit 9617b09 into Netflix:master Aug 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants