Open johanandren opened 2 years ago
Ofc. being able to drop/ignore packages when you cannot keep up is one of the points with UDP so maybe the right thing here is to "fix" documentation and describe how to combine with a buffer to handle incoming messages when stream is backpressuring if that's important in a given application.
With the current behavior we don't make any use of the OS-level receive buffers because those are immediately drained. That basically means zero buffering which will not work well with UDP where packets might come in bursts.
One workaround would be to add a .buffer
element after the UDP source.
So, I think eventually we should try to enforce backpressure to use the OS-level buffers by default. However, the amount of buffering needs to be tuned for UDP applications which usually have some real-time requirements. In that case, keeping a buffer of old packets while dropping new ones might not be the best strategy. So, we should probably make backpressure configurable.
The UDP bind flow does not have a buffer for incoming UDP packages and silently drops incoming if there is backpressure (see https://github.com/akka/alpakka/blob/master/udp/src/main/scala/akka/stream/alpakka/udp/impl/UdpBind.scala#L53 )
This probably not what you'd expect and it is not documented, the docs instead state:
Since incoming packets happen out of band/asynchronously and come through the stage actor ref I think it would not be enough to recommend a downstream buffer, the operator itself would need to have a receive buffer and contain logic for what to do on buffer overflow.