Reputation: 9499
I recently discovered this line in my Gemfile
:
# Use unicorn as the app server
# gem 'unicorn'
I have 2 questions.
Why would I want to use unicorn over the default WEBrick
?
How do I get it to work? I uncommented that line, ran bundle install
and then rails server
and it still booted up WEBrick
Upvotes: 1
Views: 281
Reputation: 29349
Reasons why you would use Unicorn instead of WEBrick?
How to run unicorn locally?
gem 'unicorn'
in GemfileCreate unicorn.rb
file in config/
and add the following line. You can increase the number of processes if you want to
worker_processes 1
start unicorn using the following command
unicorn -c config/unicorn.rb
Upvotes: 2
Reputation: 2865
You can also use the unicorn_rails gem which will override default webrick and unicorn instead
https://github.com/samuelkadolph/unicorn-rails
Upvotes: 1
Reputation: 13344
While this is mostly an opinion answer, Unicorn supports multiple "worker" processes to handle concurrent web requests by executing one instance of Unicorn. The number of worker processes you can run depends on the specs of the hardware, but generally 3-4 workers is safe for small servers and even development machines. You'd need multiple WEBrick processes for concurrent requests. I've also found Unicorn to be faster than WEBrick, especially in production applications and apps running on Heroku. Heroku actually has some really good documentation on this that is applicable outside of Heroku as well.
Take a look at the Unicorn gem documentation as well as the Heroku docs above. TL;DR - you'll use the command unicorn
instead of rails server
to run your app using Unicorn.
Upvotes: 1