Reputation: 653
In my rails app i do a nslookup using a ruby library resolv
. If the site like dgdfgdfgdfg.com
is entered its talking too long to resolve. in some instance like 20 sec.(mostly for non-existent sites) Because it cause the application to slowdown.
So i though of introducing a timeout period for the dns lookup.
What will be the ideal timeout period for the dns lookup so that resolution of actual site doesnt fail. will something like 10 sec will be fine?
Upvotes: 2
Views: 7236
Reputation: 339896
There's no IETF mandated value, although §6.1.3.3 of RFC 1123 suggests a value not less than 5 seconds.
Perl's Net::DNS
and the command line dig
utility do default to 5 seconds between retries. Some versions of the Microsoft resolver appear to default to 3 seconds.
Upvotes: 5
Reputation: 11497
You can run some tests among the users to find out the right number compromising responsiveness / performance.
Also you can adjust that timeout dinamically depending on the network traffic.
For example, for every sucessful resolv
, you save how much time it took you to resolv it. And every hour (for example) you can calculate an average and set double of its value as timeout (Remember that "average" is, roughly speaking, "the middle"). This way if your latency is high at some point, it autoadjust itself to increase the timeout period.
Upvotes: 2