I tried profiling a gRPC java server. And i see the below set of thread pools majorly.
gRPC Java server is exposed closer to Jetty/Tomcat style, except that it is asynchronous. That is, in normal Servlets each request consumes a thread until it is complete. While newer Servlet versions let you detach from the dedicated thread and continue work asynchronously (freeing the thread for other use) that is more uncommon. In gRPC you are free to work in either style. Note that gRPC uses a cachedThreadPool by default to reuse threads; on server-side it's a good idea to replace the default executor with your own, generally fixed-size, pool via ServerBuilder.executor()
.
Internally gRPC Java uses the Netty-style. That means fully non-blocking. You may use ServerBuilder.directExecutor()
to run on the Netty threads. Although in that case you may want to specify the NettyServerBuilder.bossEventLoopGroup()
, workerEventLoopGroup()
, and for compatibility channelType()
.