Is UDP socket in the active mode anit-pattern?

Hi, do you have any experience in using UDP sockets in the active mode? On the one hand, having a socket in the passive mode, you won’t overwhelm your application as you read as fast as you can. On the other hand, if you don’t read fast enough, UDP datagrams will be dropped out and you have to deal with packet loss.
Either way, you have a problem so I would favor active mode as it’s easier to notice that your app is slowing down and memory usage is growing up.

I was looking for some projects and most of them use the passive mode e.g.:

  • stun - passive mode or active,N both for TCP and UDP
  • ejabberd - both passive and acitve modes
  • rabbit - only passive mode
  • cowboy - passive mode or active,N

Not remotely an Erlang socket expert, but my understanding is the whole point of UDP is that you will have to deal with packet loss - whether from the local endpoint dropping stale packets, or from some intermediate host dropping them.

1 Like

You are correct. On the other hand, you have a connection-less setup and ability to do broadcast and multicast.