Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the grpc server use one new goroutine to process one method call?

Tags:

go

grpc

How does golang grpc implementation handle the server concurrency?

One goroutine per method call? Or sort of goroutine pool?

Does it depend on the concurrency model of net/http2?

like image 212
kingluo Avatar asked May 16 '18 08:05

kingluo


People also ask

Can gRPC server handle multiple clients?

Multiple gRPC clients can be created from a channel, including different types of clients. A channel and clients created from the channel can safely be used by multiple threads. Clients created from the channel can make multiple simultaneous calls.

Are gRPC calls synchronous?

Additionally, a gRPC RPC can be synchronous or asynchronous. Synchronous: a client call waits for the server to respond. Asynchronous: client makes non-blocking calls to the server, and the server returns the response asynchronously.

How does gRPC communicate?

In gRPC, the client triggers communication, which consists of request headers, binary messages (this is known as a length-prefixed message), and end-of-stream flag to notify the server that the client finished sending the content.

Does gRPC need connection pool?

gRPC builds on top of this foundation with connection pooling, health semantics, efficient use of data frames and multiplexing, and KeepAlive. Developers choosing protocols must choose those that meet today's demands as well as tomorrow's.


1 Answers

One goroutine per method call. There's current no goroutine pool for service handlers.

It doesn't depend on net/http2 concurrency model.

https://github.com/grpc/grpc-go/blob/master/Documentation/concurrency.md#servers

like image 110
menghanl Avatar answered Nov 02 '22 13:11

menghanl