Play around with workflows to see if it improves performance. The standard constructor NioEventLoopGroup() creates the default number of event loop threads:
DEFAULT_EVENT_LOOP_THREADS = Math.max(1, SystemPropertyUtil.getInt( "io.netty.eventLoopThreads", Runtime.getRuntime().availableProcessors() * 2));
As you can see, you can pass io.netty.eventLoopThreads as a start argument, but I usually don't.
You can also pass the number of threads in the NioEventLoopGroup() constructor.
In our environment, we have network servers that receive messages from hundreds of clients. Typically, a single boss thread is enough to handle connections. However, it is necessary to reduce the number of workflows. We use this:
private final static int BOSS_THREADS = 1; private final static int MAX_WORKER_THREADS = 12;
EventLoopGroup bossGroup = new NioEventLoopGroup(BOSS_THREADS); EventLoopGroup workerGroup = new NioEventLoopGroup(calculateThreadCount());
private int calculateThreadCount() { int threadCount; if ((threadCount = SystemPropertyUtil.getInt("io.netty.eventLoopThreads", 0)) > 0) { return threadCount; } else { threadCount = Runtime.getRuntime().availableProcessors() * 2; return threadCount > MAX_WORKER_THREADS ? MAX_WORKER_THREADS : threadCount; } }
So, in our case, we use only one boss stream. Workflows depend on the start argument. If not, use kernels * 2, but no more than 12.
You will have to test yourself, although which numbers are best for your environment.
source share