AutoScalingEventExecutorChooserFactory.java — netty Source File
Architecture documentation for AutoScalingEventExecutorChooserFactory.java, a java file in the netty codebase.
Entity Profile
Relationship Graph
Source Code
/*
* Copyright 2025 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.util.concurrent;
import io.netty.util.internal.ObjectUtil;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
/**
* A factory that creates auto-scaling {@link EventExecutorChooser} instances.
* This chooser implements a dynamic, utilization-based auto-scaling strategy.
* <p>
* It enables the {@link io.netty.channel.EventLoopGroup} to automatically scale the number of active
* {@link io.netty.channel.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.
* <p>
* An {@code EventLoop} can be suspended if its utilization is consistently below the
* {@code scaleDownThreshold}. Conversely, if the group's average utilization is consistently
* above the {@code scaleUpThreshold}, a suspended thread will be automatically resumed to handle
* the increased load.
* <p>
* To control the aggressiveness of scaling actions, the {@code maxRampUpStep} and {@code 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
* {@code scalingPatienceCycles} defines how many consecutive monitoring windows a condition must be met
* before a scaling action is triggered.
*/
public final class AutoScalingEventExecutorChooserFactory implements EventExecutorChooserFactory {
/**
* A container for the utilization metric of a single EventExecutor.
* This object is intended to be created once and have its {@code utilization}
* field updated periodically.
*/
public static final class AutoScalingUtilizationMetric {
private final EventExecutor executor;
private final AtomicLong utilizationBits = new AtomicLong();
AutoScalingUtilizationMetric(EventExecutor executor) {
this.executor = executor;
}
// ... (362 more lines)
Domain
Subdomains
Classes
Source
Frequently Asked Questions
What does AutoScalingEventExecutorChooserFactory.java do?
AutoScalingEventExecutorChooserFactory.java is a source file in the netty codebase, written in java. It belongs to the CommonUtil domain, Concurrent subdomain.
Where is AutoScalingEventExecutorChooserFactory.java in the architecture?
AutoScalingEventExecutorChooserFactory.java is located at common/src/main/java/io/netty/util/concurrent/AutoScalingEventExecutorChooserFactory.java (domain: CommonUtil, subdomain: Concurrent, directory: common/src/main/java/io/netty/util/concurrent).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free