Tristan Tao
Tristan Tao

Reputation: 875

Is it bad/pointless to setup a Nginx/Unicorn/Rails local dev environment if I want faster speed?

So I currently run a Nginx/Unicorn/Rails setup on a production box. However, I've always done a local deployment for dev purpose via:

rails s

I noticed that this wasn't the fastest (or way slower than the prod box, and yea I recognize that the prod box is way more powerful), so I decided to try running the production setup on my local setup. That meant setting up nginx, uncorn, multiple workers etc etc.

What I'm seeing is that it's slightly faster (This could be very much placebo). I also realize that the benefits from unicorn come from being able to handle multiple requests (which on my local setup is ridiculous, since I'm the only request ever).

Overall, what would be a good local setup if I want to speed up my local box? I'm relatively inexperienced in this area so any thoughts will be appreciated. Also if there is no better way, I'm ok with that too. The benefit of rails outweighs the sometimes slow speed for me anyways.

Upvotes: 1

Views: 237

Answers (1)

infused
infused

Reputation: 24347

A big reason that Rails is slower in the development environment is that it reloads all your models, controllers, etc on every request. Everything is pre-loaded on production. That being said, webrick is very slow and I find that using thin in development is much faster.

To use thin, simple add it to your Gemfile:

group :development do
  gem 'thin'
end

When you fire up the server it should tell you it is using thin. If it doesn't you may have to specify it manually:

rails server thin

Upvotes: 1

Related Questions