mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-14 18:19:28 +00:00
perf[net]: 优化boss group线程池数量
This commit is contained in:
1 parent
c774bd7529
commit
902406c6bd
2 files changed
+4
-3
No files matched your search
@@ -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))
|
||||
|
||||
Reference in new issue
Block a user