Skip to content

Backpressure support #14

@fillson-shady

Description

@fillson-shady

Hello!
First of all thank you for the great library! That is what I was looking for.

I have question about backpressure support in streaming scenarios.
I have created simple test with client streaming to server with a large chunks of bytes. It works great with a performance near native java-gRPC libraries shows. However, when I have added ZIO.sleep to a service logic, test became crushing with an OutOfMemory error (on both client and server side).

There is a great library salesforce/reactive-grpc which provides backpressure support for java world. Is there any plans to implement such functionality in zio-grpc?

Btw, there is a simple workaround can be used for now:

def clientLogic = for {
  data      <-  //some big, maybe unbounded data stream
  queue     <- Queue.bounded[Request](10)     //10 is buffer size
  _         <- queue.offerAll(data.take(10))  //initial request for a data
  _         <- GeneratedService
    .send(Stream.fromQueue(queue))
    .tap(demand => queue.offerAll(data.take(demand.count)))
    .runDrain
} yield ()

Here client sends some amount of data to the server and after some processing server responses to client with a Demand(count: Int) message, which signalises that server is ready accept more data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions