Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8592665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:48:17+00:00 2026-06-11T23:48:17+00:00

We use Ruby to check domain availability, but the code runs painfully slow. We

  • 0

We use Ruby to check domain availability, but the code runs painfully slow. We caching the Whois object across requests would accelerate performance, but other posts on SO suggest this would only marginally increase performance, if at all.

The code is so simple. We’re not sure if other improvements could be made, or if we’re just stuck with slow lookups because of the Whois object.

The bulk_check method accepts an array of domains to look up. Everything else is fairly self-explanatory.

We’re on Rails 3.

Any suggestions?

Thanks!

def bulk_check
    domains = params[:domains] || '[]'
    callback = params[:callback] || ''      
    results = []
    threads = []

    # String -> Array
    domains = ActiveSupport::JSON.decode domains

    # Iterate over each domain and spawn new thread to check domain status
    domains.each do |d|
      threads << Thread.new(d) { |my_domain|
        Thread.current['domain'] = my_domain
        Thread.current['status'] = get_domain_status my_domain
      }
    end

    # Wait for threads to finish and update results array
    threads.each do |t| 
        t.join
        results.push [ t['domain'], t['status'] ]
    end

    # Render results
    respond_to do |type|
        type.json { render :json => { :results => results }.to_json, :callback => callback }
    end
end


def get_domain_status domain
    begin
        # Create Whois object
        whois = Whois::Client.new

        # Query Whois for domain data
        result = whois.query domain

        # Prep JSON response
        status = result.available? ? 'available' : 'taken'
    rescue Exception => e
        puts "Exception in parsing '#{domain}' status: #{e.message}"
        status = 'error'
    end

    # Return status
    return status
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:48:19+00:00Added an answer on June 11, 2026 at 11:48 pm

    Since this is not really a CPU intensive operation, but rather a “network intensive” – consider checking multiple domains simultaneously using Ruby threads or fibers.

    For example, Celluloid gem makes it nice and easy: https://github.com/celluloid/celluloid/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use MacRuby to tell Mail.app to check for new email. But
I am using Ruby on Rails 3.0.7 and I would like to use check
I have a code to do a check of nil in ruby. So what
I use the following code to check the server status of a certain game
Is there a way to check for an HTTPS status code in ruby? I
I use Ruby on Rails 2.3 and gem 'tiny_mce' Gem uses TinyMCE 3.4 Gem
I would like to use Ruby Net::SMTP to send email. The routine send_message( msgstr,
I have to type rvm use ruby-1.9.3 every time I login to my server.
I want to write a web application and want to use Ruby. I have
I have the ruby version manager installed and use the ruby implementation installed by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.