tags:

views:

39

answers:

2

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?

+1  A: 

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.

pakore
yeah i can do that. but for a quick fix. is there anything like a most resonable timeout period?
railscoder
There's no magic number. But I guess for me 5 seconds is enough for a resolv.Anyway, you should start accepting answers, your accept rate is really low :)
pakore
+1  A: 

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.

Alnitak