Class AutoScalingEventExecutorChooserFactory

  • All Implemented Interfaces:
    EventExecutorChooserFactory

    public final class AutoScalingEventExecutorChooserFactory
    extends java.lang.Object
    implements EventExecutorChooserFactory
    A factory that creates auto-scaling 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.

    • 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-enabled EventExecutorChooserFactory.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 for utilizationWindow.
        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.