Script running 30 hours. Something I doing wrong?

So I know I’m looping through a metric ton of information here, but this
has been running for 30 hours now. Anyone notice anything that might be
wrong?

require ‘rubygems’
require ‘whois’

doms = Array.new
avail = Array.new

456976.times do |i|
i = rand(36**4).to_s(36)
doms.push("#{i}.com")
end

doms = doms.uniq

puts “** Preparing to check #{doms.length.to_s} domains **”

doms.each { |i|
begin
if r = Whois.whois("#{i}").available?
puts “+ #{i}”
avail.push("#{i}")
end
rescue
puts “- Exception caught.”
end
}

puts “+ There are #{avail.length.to_s} domains available. Saving
output.”

avail.each { |i|
begin
File.open(‘domains.log’, ‘w’) { |file| file.write(i) }
rescue
end
}

30 hours / 456976 request = 0.24 seconds / request

I don’t know how fast it can do one request, but the server probably
limit the number of requests.

You could

  • print some status info, ie. puts i for every iteration of the loop.
  • Save the info to file as soon as it becomes available and don’t wait
    until the loop finishes. That way you don’t have to do it all at once.

Well I actually did some math after posting this and figured the script
would take about 55 hours to loop through all the records.