[Sussex] Ruby DNS resolver

Ronan Chilvers ronan at thelittledot.com
Thu Sep 7 08:02:02 UTC 2006


On Wed, Sep 06, 2006 at 02:45:56PM +0100, Nic James Ferrier wrote:
> Ronan Chilvers <ronan at thelittledot.com> writes:
> Have you tried:
> 
>   strace ruby -e "require 'resolv'; res=Resolv::DNS.new; p res.getresource('dynablock.njabl.org',Resolv::DNS::Resource::IN::A)"

Gave it a try. Turns out that a lot of time is spent waiting for
select() calls. We have a internal DNS server (dnsmasq) here which 
forwards to an external source. If I take the forwarder out of the
equation (ie: remove it from resolv.conf) lookups speed up dramatically.

Original script with forwarder with calls to 4 dnsbls:
ronan at rncubuntu:rbl $ time ruby dnsbl.rb
"Checking 119.110.88.24.list.dsbl.org"
"Checking 119.110.88.24.ns1.njabl.org"
"Checking 119.110.88.24.sbl-xbl.spamhaus.org"
"Checking 119.110.88.24.relays.ordb.org"
"DNSBL_DSBL: 1.1"
"DNSBL_DYN_NJABL: 0"
"DNSBL_SPAMHAUS: 4.35"
"DNSBL_ORDB: 0"
"SCORE: 5.45"

real    1m5.171s
user    0m0.028s
sys     0m0.004s


Without forwarder:
ronan at rncubuntu:rbl $ time ruby dnsbl.rb
"Checking 119.110.88.24.list.dsbl.org"
"Checking 119.110.88.24.ns1.njabl.org"
"Checking 119.110.88.24.sbl-xbl.spamhaus.org"
"Checking 119.110.88.24.relays.ordb.org"
"DNSBL_DSBL: 1.1"
"DNSBL_DYN_NJABL: 0"
"DNSBL_SPAMHAUS: 4.35"
"DNSBL_ORDB: 0"
"SCORE: 5.45"

real    0m0.187s
user    0m0.032s
sys     0m0.004s

Sheesh!!! Going to investigate further - speed hasn't been an issue with
the forwarder in the past so maybe something unpleasant is lurking in
the DNS woodshed.

Thanks for the help Nic!

Cheers
-- 
Ronan
e: ronan at thelittledot.com
t: 01903 739 997

This email has been digitally signed using GNUPG to verify the identity
of the sender. Please see http://www.gnupg.org/ for further information.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: Digital signature
Url : http://mailman.lug.org.uk/pipermail/sussex/attachments/20060907/d5eaefb5/attachment.pgp 


More information about the Sussex mailing list