Class AutoScalingEventExecutorChooserFactory
- All Implemented Interfaces:
EventExecutorChooserFactory
EventExecutorChooserFactory.EventExecutorChooser instances.
This chooser implements a dynamic, utilization-based auto-scaling strategy.
It enables the EventLoopGroup to automatically scale the number of active
EventLoop threads between a minimum and maximum threshold.
The scaling decision is based on the average utilization of the active threads, measured over a
configurable time window.
An EventLoop can be suspended if its utilization is consistently below the
scaleDownThreshold. Conversely, if the group's average utilization is consistently
above the scaleUpThreshold, a suspended thread will be automatically resumed to handle
the increased load.
To control the aggressiveness of scaling actions, the maxRampUpStep and maxRampDownStep
parameters limit the maximum number of threads that can be activated or suspended in a single scaling cycle.
Furthermore, to ensure decisions are based on sustained trends rather than transient spikes, the
scalingPatienceCycles defines how many consecutive monitoring windows a condition must be met
before a scaling action is triggered.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA container for the utilization metric of a single EventExecutor.Nested classes/interfaces inherited from interface EventExecutorChooserFactory
EventExecutorChooserFactory.EventExecutorChooser, EventExecutorChooserFactory.ObservableEventExecutorChooser -
Constructor Summary
ConstructorsConstructorDescriptionAutoScalingEventExecutorChooserFactory(int minThreads, int maxThreads, long utilizationWindow, TimeUnit windowUnit, double scaleDownThreshold, double scaleUpThreshold, int maxRampUpStep, int maxRampDownStep, int scalingPatienceCycles) Creates a new factory for a scaling-enabledEventExecutorChooserFactory.EventExecutorChooser. -
Method Summary
Modifier and TypeMethodDescriptionnewChooser(EventExecutor[] executors) Returns a newEventExecutorChooserFactory.EventExecutorChooser.
-
Constructor Details
-
AutoScalingEventExecutorChooserFactory
public AutoScalingEventExecutorChooserFactory(int minThreads, int maxThreads, long utilizationWindow, TimeUnit windowUnit, double scaleDownThreshold, double scaleUpThreshold, int maxRampUpStep, int maxRampDownStep, int scalingPatienceCycles) Creates a new factory for a scaling-enabledEventExecutorChooserFactory.EventExecutorChooser.- Parameters:
minThreads- the minimum number of threads to keep active.maxThreads- the maximum number of threads to scale up to.utilizationWindow- the period at which to check group utilization.windowUnit- the unit forutilizationWindow.scaleDownThreshold- the average utilization below which a thread may be suspended.scaleUpThreshold- the average utilization above which a thread may be resumed.maxRampUpStep- the maximum number of threads to add in one cycle.maxRampDownStep- the maximum number of threads to remove in one cycle.scalingPatienceCycles- the number of consecutive cycles a condition must be met before scaling.
-
-
Method Details
-
newChooser
Description copied from interface:EventExecutorChooserFactoryReturns a newEventExecutorChooserFactory.EventExecutorChooser.- Specified by:
newChooserin interfaceEventExecutorChooserFactory
-