-
Scenario: We are receiving huge amount of voice data streams which could be upto couple of minutes long. There will huge set of data streams as an input every second. This a real time application where I get live data from multiple users and return response from api. I am using google' AsyncStreamingRecognize to create stream. This stream open, read and write functions are blocking as I cannot proceed with other operation until success is returned by Is there a better way to where I can write high amount of input data without my thread being blocked for previous write function ? The code/setup works fine for a single call in real time. But I doubt how to design it well that could handle huge realtime incoming traffic |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
You can set up a callback to be triggered when the You would need to create one of these With that said, if you can use C++20 coroutines, then consider doing so. The code is far more readable than using callbacks, and it basically does the same thing: In either case, you may want to increase the number of background threads if a single CPU cannot keep up. There is an option to set the size of the background thread pool. Eventually you may need to create your own thread pool. |
Beta Was this translation helpful? Give feedback.
-
It seems like you're using Google's AsyncStreamingRecognize for processing streaming data, but you're encountering issues with blocking functions, particularly with regards to writing large amounts of input data. To handle high traffic in real-time scenarios, you might want to consider implementing a more asynchronous approach. One suggestion is to utilize asynchronous I/O libraries or frameworks, like Python's asyncio module. This would allow you to perform non-blocking I/O operations, ensuring that your threads are not unnecessarily held up. |
Beta Was this translation helpful? Give feedback.
A
google::cloud::CompletionQueue
is a wrapper aroundgrpc::CompletionQueue
, but with a (I hope) nicer interface. It may be easier to explain the problem these things solve so you can get some context.Assume you have an application that is using asynchronous operations (RPCs and timers in our case). You may have many asynchronous operations pending at a time. You want to get notified when an operation completes. Those notifications cannot run in the application threads. The whole reason you wanted to use asynchronous operations was to free your threads to do other work. Therefore, you need a pool …