>From my understanding of the C-core and C++ wrapper for gRPC, it does not create threads; it borrows. You must provide your own threads to handle streaming messages. You can wait on multiple actions within a single thread.
On Tuesday, January 3, 2017 at 4:56:02 PM UTC-8, [email protected] wrote: > > Thanks for your reply. > > I am using c++. > > For my first question. Can you please explain a bit more? I tested with > two concurrent client requests. I saw two threads running in my service > routine. My server code does not spawn any thread. So I think gRPC spawns > the thread for me. That is why I want to understand the thread model. Is it > one thread per one client? or there is a thread pool for all clients? > > Thank you! > > Carl Mastrangelo於 2017年1月3日星期二 UTC-8下午4時35分42秒寫道: >> >> Each stream does not require a separate thread; gRPC multiplexes these >> onto your threads. It is slightly different for each language, but in >> general threading isn't that much of a problem. >> >> >> As for your second question, can you mention what language you are using? >> That will affect the answer. >> >> On Tuesday, January 3, 2017 at 10:27:41 AM UTC-8, [email protected] >> wrote: >>> >>> Hello, >>> >>> I am very interested in the gRPC bi-directional streaming feature. I >>> have a few questions on the server side. In the .proto file, I define a >>> simple streaming RPC and message below >>> >>> service MfMessaging { >>> rpc MfRpc (stream MfStream) returns (stream MfStream) {} >>> } >>> message MfStream { >>> bytes message=1; >>> } >>> >>> My first question is: what is the thread model at server side? I mean >>> how gRPC handles if there are multiple concurrent requests from different >>> clients? Does gRPC spawn a thread for each client? If yes, is there any >>> limit or gRPC has a thread pool underneath? >>> >>> My second question is: In the service routine, I get a >>> ServerReaderWriter stream (e.g. ServerReaderWriter<MfStream, MfStream>* >>> stream). What is lifetime of this stream? Can I pass this stream to another >>> thread which writes response back later? >>> >>> Look forward to your reply. Thank you very much! >>> >>> -- 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/df57076e-169f-4db9-bf3e-f376907914a6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
