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?