Does bidirectional streaming benefit from a completion queue? (C++)

714 views
Skip to first unread message

Michael Leonard

unread,
Sep 9, 2016, 4:08:20 AM9/9/16
to grpc.io

Hi 

I'm new to grpc (love it so far!) and have a helloworld bidirectional streaming example working in C++. I made this by going through the helloworld and route_guide examples and combining the two so I can stream HelloRequest and HelloResponse messages back and forth between the C++ client and C++ server in any order I choose.

My question is: is there such a thing as 'async bidirectional streaming'? 

My understanding of async in the single non-streaming case is that it allows the program to do something else and not block while waiting for the response to the rpc. In the bidirectional streaming case I believe I can send something from the client to the server, do something else, send something else, etc... and so achieve the same non-blocking feature. 

Do I gain anything by implementing the completion queue in bidirectional streaming case, or is it only useful for the non-streaming variants?? i.e. have I got already got the most general/flexible option already working, or would using a completion queue in my bidirectional streaming code give me any extra features/advantages/possibilities?


Thanks very much in advance!

Mike

Craig Tiller

unread,
Sep 13, 2016, 7:09:53 PM9/13/16
to grpc.io
With a completion queue and using the async API, you could be multiplexing thousands of bidi streams on a single thread, and some applications really need that - most however don't. If you're not in that category, I'd encourage you to stick with the synchronous API's and keep your code simple: the async API is substantially harder to work with.

Michael Leonard

unread,
Sep 23, 2016, 12:02:09 PM9/23/16
to grpc.io
Hi Craig

That's great thanks for the clarification. I'll be returning to the C++ part of the code in a few weeks so I'll have a proper think about what I need for my use case then and perhaps will post another question I need to implement the C++ async api and get a bit stuck (quite likely!).

Thanks for the help.
Reply all
Reply to author
Forward
0 new messages