Skip to content

Commit

Permalink
Merge pull request #39 from TH1nker2/main
Browse files Browse the repository at this point in the history
netty服务的worker的EventLoopGroup大小根据当前cpu核心数动态获取
  • Loading branch information
zongzibinbin authored Jun 16, 2023
2 parents ab7d06d + a3eeb4e commit c8c20aa
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.stream.ChunkedWriteHandler;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.util.NettyRuntime;
import io.netty.util.concurrent.Future;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
Expand All @@ -28,7 +29,7 @@ public class NettyWebSocketServer {
public static final int WEB_SOCKET_PORT = 8090;
// 创建线程池执行器
private EventLoopGroup bossGroup = new NioEventLoopGroup(1);
private EventLoopGroup workerGroup = new NioEventLoopGroup(8);
private EventLoopGroup workerGroup = new NioEventLoopGroup(NettyRuntime.availableProcessors());

/**
* 启动 ws server
Expand Down

0 comments on commit c8c20aa

Please # to comment.