Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webrick is very slow to respond. How to speed it up?

Having the same issue here (even a year later). Under linux you have to do the following:

Look for the file /usr/lib/ruby/1.9.1/webrick/config.rb and edit it.

Replace the line

:DoNotReverseLookup => nil,

with

:DoNotReverseLookup => true,

Restart webrick and it'll work like a charm :)


Had the same problem. For me, this post held the solution. If you are on Ubuntu, stop (or uninstall) the avahi-daemon. service avahi-daemon stop stops the daemon.

Webrick now feels very speedy.

The problem has an old report in Rails Lighthouse, however, Ruby-on-Rails have moved their tickets to github since then; Kind of unfortunate that this old problem persists still.

Be aware though, that if you actually use avahi-daemon for something, like finding printers and scanners on your network, that won’t work anymore.


Just had the same problem. The

...
:DoNotReverseLookup => true,
...

did the trick for me too. Just in case you´re running ruby under the rvm, here is the path to go for:

~/.rvm/rubies/ruby-<version>/lib/ruby/<version>/webrick/config.rb

"Thin" is now a great option for running both locally and on Heroku:

On Heroku: https://devcenter.heroku.com/articles/rails3#webserver

Website: http://code.macournoyer.com/thin/

You can use it locally by putting in your Gemfile:

gem "thin"

... and then run bundle and start your server with thin start or rails s.

Update on Heroku

Thin is now considered a bad choice for Heroku. More information here:

https://blog.heroku.com/archives/2013/4/3/routing_and_web_performance_on_heroku_a_faq

Their recommendation:

Switch to a concurrent web backend like Unicorn or Puma on JRuby, which allows the dyno to manage its own request queue and avoid blocking on long requests.


I had a vaguely similar problem that manifested itself when accessing a WEBrick server via a VPN. Requests would take a long time, most of it with nothing happening on the wire. Since neither mongrel nor thin gems worked with Ruby1.9 on Windows and there was no way I was getting myself embroiled in compiling stuff from source, I needed to stick with WEBrick.

The fix was to set the config parameter DoNotReverseLookup to true, when creating the WEBrick server:

server = HTTPServer.new {:DoNotReverseLookup => true, ...}