I am using Erlang via Rabbitmq. The client and server are on the same node and communicate using the loopback address. When the DNS server is unreachable or slow, the connection takes a long time. strace shows, its stuck reading from 127.0.0.1. I believe this is due to the reverse dns lookup performed by erlang. And this is contributing to the delay. How do we disable this in erlang? Environment variable inetrc based approach ( with reverse set to false) doesn’t seem to work
Update: Found that, its the normal dns lookup for the hostname thats causing the delay. (not revere lookup). And erlang prefers external dns server ( the one defined in /etc/resolv.conf) to /etc/hosts. Is there way to force it to lookup /etc/hosts?
By default, the Erlang internal resolver functions use only the “native” resolver, which is a pool of helper programs that call the system’s native resolver. Maybe you could make the system resolver use files before dns. Unfortunately it has become increasingly “interesting” to tweak the system resolver nowadays; editing /etc/resolv.conf is often a task reserved for system programs, but it should still be possible…
You could also change the Erlang resolver configuration in the Kernel application to use [file,native]
. Then the content of /etc/hosts is parsed into ETS tables and use for lookup in that order. There might be surprises if you edit the /etc/hosts file, in how fast the ETS tables are updated, if at all…
Thanks. You are right. I read about that behaviour after posting on this thread. Tried specifying a inetrc file with the lookup order and stuff. That did the trick.
Thanks a lot anyways for the prompt response.