You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2019/11/13 00:22:53 UTC
[servicecomb-pack] 01/02: SCB-1585 Optimize the Netty server thread
model to split bossEventLoopGroup and workerEventLoopGroup
This is an automated email from the ASF dual-hosted git repository.
ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-pack.git
commit 740f45b4799b446c9c49e6bdc1f17596e0411492
Author: Lei Zhang <zh...@apache.org>
AuthorDate: Tue Nov 12 15:46:11 2019 +0800
SCB-1585 Optimize the Netty server thread model to split bossEventLoopGroup and workerEventLoopGroup
---
.../apache/servicecomb/pack/alpha/server/GrpcStartable.java | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/GrpcStartable.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/GrpcStartable.java
index 23b258e..139b33b 100644
--- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/GrpcStartable.java
+++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/GrpcStartable.java
@@ -20,6 +20,8 @@
package org.apache.servicecomb.pack.alpha.server;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
import java.io.IOException;
import java.io.InputStream;
import java.lang.invoke.MethodHandles;
@@ -45,7 +47,6 @@ import io.grpc.netty.NettyServerBuilder;
import io.netty.handler.ssl.ClientAuth;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.SslProvider;
-import org.springframework.context.ApplicationEventPublisher;
public class GrpcStartable implements ServerStartable {
@@ -63,7 +64,10 @@ public class GrpcStartable implements ServerStartable {
if(unusedPort.isPresent()){
if (serverConfig.isSslEnable()){
serverBuilder = NettyServerBuilder.forAddress(
- new InetSocketAddress(serverConfig.getHost(), unusedPort.getAsInt()));
+ new InetSocketAddress(serverConfig.getHost(), unusedPort.getAsInt()))
+ .channelType(NioServerSocketChannel.class)
+ .bossEventLoopGroup(new NioEventLoopGroup(1))
+ .workerEventLoopGroup(new NioEventLoopGroup());
try {
((NettyServerBuilder) serverBuilder).sslContext(getSslContextBuilder(serverConfig).build());
@@ -71,7 +75,10 @@ public class GrpcStartable implements ServerStartable {
throw new IllegalStateException("Unable to setup grpc to use SSL.", e);
}
} else {
- serverBuilder = ServerBuilder.forPort(unusedPort.getAsInt());
+ serverBuilder = NettyServerBuilder.forPort(unusedPort.getAsInt())
+ .channelType(NioServerSocketChannel.class)
+ .bossEventLoopGroup(new NioEventLoopGroup(1))
+ .workerEventLoopGroup(new NioEventLoopGroup());
}
Arrays.stream(services).forEach(serverBuilder::addService);
server = serverBuilder.build();