3

I use akka-streams' ActorPublisher actor as a streaming per-connection Source of data being sent to an incoming WebSocket or HTTP connection.

ActorPublisher's contract is to regularly request data by supplying a demand - number of elements that can be accepted by downstream. I am not supposed to send more elements if the demand is 0. I observe that if I buffer elements, when consumer is slow, that buffer size fluctuates between 1 and 60, but mostly near 40-50.

To stream I use akka-http's ability to set WebSocket output and HttpResponse data to a Source of Messages (or ByteStrings).

I wonder how the back-pressure works in this case - when I'm streaming data to a client through network. How exactly these numbers are calculated? Does it check what's happening on network level?

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
Tvaroh
  • 6,645
  • 4
  • 51
  • 55
  • I *think* that akka-streams I/O layer delegates to TCP backpressure, but I don't have proof - the I/O code there is too hard for me to decipher :( – Vladimir Matveev Jun 14 '17 at 04:12

1 Answers1

2

The closest I could find for your question "how the back-pressure works in this case" is from the documentation:

Akka HTTP is streaming all the way through, which means that the back-pressure mechanisms enabled by Akka Streams are exposed through all layers–from the TCP layer, through the HTTP server, all the way up to the user-facing HttpRequest and HttpResponse and their HttpEntity APIs.

As to "how these numbers are calculated", I believe that is specified in the configuration settings.

Ramón J Romero y Vigil
  • 17,373
  • 7
  • 77
  • 125