flinkcdc 中有用到netty,源码如下
NioEventLoopGroup workerGroup =
new NioEventLoopGroup(
0, new ExecutorThreadFactory("flink-rest-server-netty-worker"));
以上代码设置线程数是0,但是NioEventLoopGroup初始化时
private static final int DEFAULT_EVENT_LOOP_THREADS = Math.max(1, SystemPropertyUtil.getInt("org.apache.flink.shaded.netty4.io.netty.eventLoopThreads", NettyRuntime.availableProcessors() * 2));
是根据系统参数org.apache.flink.shaded.netty4.io.netty.eventLoopThreads 和 cpu核数决定的(NettyRuntime.availableProcessors() * 2);
System.setProperty("org.apache.flink.shaded.netty4.io.netty.eventLoopThreads", "8");
启动时设置具体线程数。
默认线程数为cpu核数*2