Search code examples
ruby-on-railsrubywebrick

Slow localhost load running Rails and Webrick


I am running Rails on in my development environment and Webrick is unbearably slow. I am not really able to find out why.

The CPU utilization bounces between 6 and 12%, and the memory utilization hovers at 18% throughout the load.

I found a website where the author recommended changing the webrick config (...\lib\ruby\2.0.0\webrick\config.rb):

General + {
...
      #:DoNotReverseLookup => nil, #original setting
      :DoNotReverseLookup => true,
}

I also rebooted my box in case something like that was the solution, but no change.

Here is the load:

slow load

What is causing this slow load and how do I fix it?

Edit: I am using a Windows 7 dev environment, 24 GB, 3.1 GHz, running postgres.


Solution

  • WEBrick is doing a reverse DNS lookup on connecting IPs by default. In other words, it's trying to see if your IP address is associated with a domain name. This is unnecessary and takes too long, so you can disable it.

    Open the file "l/ruby/lib/ruby/1.9.1/webrick/config.rb" and locate the line with ":DoNotReverseLookup => nil". Change nil to true.

    Enjoy!