perf[net]: 优化boss group线程池数量

This commit is contained in:
jaysunxiao
2022-06-01 17:37:23 +08:00
parent c774bd7529
commit 902406c6bd
2 changed files with 4 additions and 3 deletions
@@ -68,9 +68,10 @@ public abstract class AbstractServer implements IServer {
protected synchronized void doStart(ChannelInitializer<? extends Channel> channelChannelInitializer) {
var cpuNum = Runtime.getRuntime().availableProcessors();
// 一条线程持有一个端口对应的selector,如果我们启动不仅仅是一个服务器端口的话,为了更好的性能需要修改对应的bossGroup数量
bossGroup = Epoll.isAvailable()
? new EpollEventLoopGroup(Math.max(1, cpuNum / 4), new DefaultThreadFactory("netty-boss", true))
: new NioEventLoopGroup(Math.max(1, cpuNum / 4), new DefaultThreadFactory("netty-boss", true));
? new EpollEventLoopGroup(Math.max(1, cpuNum / 8), new DefaultThreadFactory("netty-boss", true))
: new NioEventLoopGroup(Math.max(1, cpuNum / 8), new DefaultThreadFactory("netty-boss", true));
workerGroup = Epoll.isAvailable()
? new EpollEventLoopGroup(cpuNum * 2, new DefaultThreadFactory("netty-worker", true))
@@ -3,7 +3,7 @@
#include <string>
#include "cppProtocol//ByteBuffer.h"
#include "cppProtocol/ByteBuffer.h"
namespace byte_buffer_test {