Class AutoScalingEventExecutorChooserFactory
- java.lang.Object
-
- io.netty.util.concurrent.AutoScalingEventExecutorChooserFactory
-
- All Implemented Interfaces:
EventExecutorChooserFactory
public final class AutoScalingEventExecutorChooserFactory extends java.lang.Object implements EventExecutorChooserFactory
A factory that creates auto-scalingEventExecutorChooserFactory.EventExecutorChooser
instances. This chooser implements a dynamic, utilization-based auto-scaling strategy.It enables the
EventLoopGroup
to automatically scale the number of activeEventLoop
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 thescaleDownThreshold
. Conversely, if the group's average utilization is consistently above thescaleUpThreshold
, a suspended thread will be automatically resumed to handle the increased load.To control the aggressiveness of scaling actions, the
maxRampUpStep
andmaxRampDownStep
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, thescalingPatienceCycles
defines how many consecutive monitoring windows a condition must be met before a scaling action is triggered.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.netty.util.concurrent.EventExecutorChooserFactory
EventExecutorChooserFactory.EventExecutorChooser
-
-
Constructor Summary
Constructors Constructor Description AutoScalingEventExecutorChooserFactory(int minThreads, int maxThreads, long utilizationWindow, java.util.concurrent.TimeUnit windowUnit, double scaleDownThreshold, double scaleUpThreshold, int maxRampUpStep, int maxRampDownStep, int scalingPatienceCycles)
Creates a new factory for a scaling-enabledEventExecutorChooserFactory.EventExecutorChooser
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EventExecutorChooserFactory.EventExecutorChooser
newChooser(EventExecutor[] executors)
Returns a newEventExecutorChooserFactory.EventExecutorChooser
.
-
-
-
Constructor Detail
-
AutoScalingEventExecutorChooserFactory
public AutoScalingEventExecutorChooserFactory(int minThreads, int maxThreads, long utilizationWindow, java.util.concurrent.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 Detail
-
newChooser
public EventExecutorChooserFactory.EventExecutorChooser newChooser(EventExecutor[] executors)
Description copied from interface:EventExecutorChooserFactory
Returns a newEventExecutorChooserFactory.EventExecutorChooser
.- Specified by:
newChooser
in interfaceEventExecutorChooserFactory
-
-