Thanks Avinash. I tried your example and it does seem to help. So if I'm 
emitting a stream from my server, should I be checking isReady() before 
each onNext() call? I'm currently reading an InputStream and chunking out 
to the response, so really what I'm doing is "waiting" (while/sleep) for 
isReady to be true on each read from the InputStream. This does seem to 
prevent the server throwing an OOM but not sure if this is the best way?

I really wish there were a way to do a blocking stream write/read so the 
backpressure handling was driven by the client reads. Having to wait/sleep 
or react to asynchronous messages in the server (for example, client could 
send a "pause" message, server could "sleep") feels complicated and 
brittle. Am I missing something with how I'm approaching this?

On Tuesday, October 25, 2016 at 1:55:29 AM UTC-4, Avinash Dongre wrote:
>
> I was trying out "flow control" see the example here
>
>
> https://github.com/davinash/grpc-bench/blob/master/bench/src/main/java/io/adongre/grpc/formatted/ScanFormattedServiceImpl.java
>
> Thanks
> Avinash
>
>
> On Sunday, October 23, 2016 at 8:51:35 PM UTC+5:30, Matt Mitchell wrote:
>>
>> After digging a little, it seems there is support for "flow control", 
>> although I can't seem to find any examples of how to do this. I've seen 
>> references to ClientResponseObserver, but not finding any way to integrate 
>> this either. Any pointers on how to work with gRPC's flow control - more 
>> importantly, am I on the right track here?
>>
>> - Matt
>>
>>  I just need to make sure that if the client isn't consuming quickly 
>> enough, that the server doesn't continue to push data into its buffer and 
>> then run out of memory.
>>
>> On Saturday, October 22, 2016 at 5:41:04 PM UTC-4, [email protected] 
>> wrote:
>>>
>>> Hi,
>>>
>>> I'm messing around with a Java server/client impl with grpc and would 
>>> like to have the Server stream back chunks from an InputStream. The 
>>> chunking using a bytes type seems fine, but now I'm wondering if there's a 
>>> way to do some sort of blocking-queue, so that if the client slows down 
>>> reading, the server will slow down too (I'm getting 
>>> "java.lang.OutOfMemoryError: Direct buffer memory" in the server) -- Is 
>>> this possible?
>>>
>>> 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/a23c2422-a02b-40fd-ba23-3144519a8f34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to