Reputation: 6763
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 Message
s (or ByteString
s).
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?
Upvotes: 3
Views: 206
Reputation: 17933
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.
Upvotes: 2