[erlang-questions] gen_udp:send blocks?

Roger Lipscombe roger@REDACTED
Fri Sep 7 15:20:19 CEST 2018


On 7 September 2018 at 14:13, Dmitry Kolesnikov <dmkolesnikov@REDACTED> wrote:
>
> On 7 Sep 2018, at 16.00, Roger Lipscombe <roger@REDACTED> wrote:
>
> Oh. Here's a thought: we use a hostname as the destination in
> gen_udp:send. Could that be causing blocking?
>
>
> Usually, this causes DNS resolution, which takes some time. If you have
> short DNS TTL or disable cache it might cause visible delay. I think you
> need to check config of you DNS server and resolver as well.

Yeah; this appears to be the problem. We're using consul, which has
zero TTL (by default?). This means that each call to gen_udp:send
resolves the name again. Based on the timings, it looks like this
involves a trip across the Atlantic. We want a fairly short TTL
(because otherwise how would health-check failover work?). I'll
explicitly cache the IP address and refresh it after each N messages
sent.



More information about the erlang-questions mailing list