Answers inline On Thursday, March 1, 2018 at 12:53:15 PM UTC-8, [email protected] wrote: > > > Hi Guys, > > Can someone please answer a few questions about GRPC threading model? > > If I create a ManagedChannel thusly: > > NettyChannelBuilder builder = NettyChannelBuilder.forAddress( host, port > ); > builder.eventLoopGroup( new NioEventLoopGroup(2) ); > builder.executor( new ThreadPoolExecutor( 1, 1, 0L, TimeUnit.MILLISECONDS, > new ArrayBlockingQueue<>( 10000 )); > > 1) The 2 EventLoop threads will be used to process data from the network? > 2) The single user thread will be used for callbacks from grpc layer to my > application layer? > > > Now if I change my ManagedChannel to: > > NettyChannelBuilder builder = NettyChannelBuilder.forAddress( host, port > ); > builder.eventLoopGroup( new NioEventLoopGroup(2) ); > builder.directExecutor(); > > 1) Will one of the event loop threads will do the work of user thread? >
Yes. The upside is that latency is less, (by about 25us) due to not needing a thread hop. The downside is that if you block in your application work load, you run the risk of deadlock or very high latency for other RPCs. > 2) When I try this scenario, I see that a thread called > *[grpc-default-executor-0] * is created. What does this thread intended > to do? > That may be DNS resolver, as DNS resolution is a blocking operation in java (we would love for this to be fixed!) > > Thanks > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/grpc-io. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/692feef6-69d1-4d4b-abe2-ae22ade5321f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
