Questions tagged [unicorn]

Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels. http://unicorn.bogomips.org/

Unicorn

Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels. Slow clients should only be served by placing a reverse proxy capable of fully buffering both the the request and response in between Unicorn and slow clients

Features

  • Designed for Rack, Unix, fast clients, and ease-of-debugging. We cut out everything that is better supported by the operating system, nginx or Rack.
  • Compatible with both Ruby 1.8 and 1.9. Rubinius support is in-progress.
  • Process management: Unicorn will reap and restart workers that die from broken apps. There is no need to manage multiple processes or ports yourself. Unicorn can spawn and manage any number of worker processes you choose to scale to your backend.
  • Load balancing is done entirely by the operating system kernel. Requests never pile up behind a busy worker process.
  • Does not care if your application is thread-safe or not, workers all run within their own isolated address space and only serve one client at a time for maximum robustness.
  • Supports all Rack applications, along with pre-Rack versions of Ruby on Rails via a Rack wrapper.
  • Builtin reopening of all log files in your application via USR1 signal. This allows logrotate to rotate files atomically and quickly via rename instead of the racy and slow copytruncate method. Unicorn also takes steps to ensure multi-line log entries from one request all stay within the same file.
  • nginx-style binary upgrades without losing connections. You can upgrade Unicorn, your entire application, libraries and even your Ruby interpreter without dropping clients. before_fork and after_fork hooks in case your application has special needs when dealing with forked processes. These should not be needed when the “preload_app” directive is false (the default).
  • Can be used with copy-on-write-friendly memory management to save memory (by setting “preload_app” to true).
  • Able to listen on multiple interfaces including UNIX sockets, each worker process can also bind to a private port via the after_fork hook for easy debugging.
  • Simple and easy Ruby DSL for configuration.
  • Decodes chunked transfers on-the-fly, thus allowing upload progress notification to be implemented as well as being able to tunnel arbitrary stream-based protocols over HTTP.

License

  • Unicorn is copyright 2009 by all contributors (see logs in git). It is based on Mongrel 1.1.5 and carries the same license.

  • Mongrel is copyright 2007 Zed A. Shaw and contributors. It is tri-licensed under (your choice) of the GPLv3, GPLv2 or Ruby-specific terms. See the included LICENSE file for details.

  • Unicorn is 100% Free Software.

Used by...

GitHub uses unicorn and has a great tech document about it. They also use Thin and Passenger, not only unicorn!

Questions

Configuration, installation, deployment, performance, optimization.... But please first read unicorn documentation!

125 questions
4
votes
1 answer

Unicorn workers dying

Last night at around midnight, our app fell over and I'm trying to determine why. We currently have a nginx front end server and 2 unicorn worker (app) servers on EC2. Pretty much our unicorn workers kept timing out and hence, were restarted by the…
James
  • 151
  • 1
  • 6
4
votes
1 answer

can nginx retry request if unicorn is overloaded and returns a 502?

Is it possible to have nginx retry a second backend before returning a 502 to the client? Would something like this work? Front end: # haproxy:85 => [a few app servers]:8000 # more specifically: # haproxy => [nginx => unicorn (502 when busy)] #…
Aaron Gibralter
  • 197
  • 1
  • 9
4
votes
1 answer

Writing an upstart config file for Unicorn

I've had a good hunt and can't find a good example of an upstart script for Unicorn. From what I've read however I think that upstart and unicorn might step on each others toes if I just try to set up a basic upstart config file given that unicorn…
Brendon Muir
  • 223
  • 1
  • 5
3
votes
1 answer

Rails + Nginx + Unicorn increase post data size ( 414 Request-URI Too Large)

I get 414 (Request-URI Too Large) exception on my POST Request while sending bulk date to my server. Is it possible to increase the limit of POST data? I have done following change in nginx configuration large_client_header_buffers 8 2024k; But it…
Sivakumar
  • 131
  • 4
3
votes
2 answers

Explain load-balancing with Nginx like I'm five

I've found plenty of DIY posts and tutorials on how to configure Nginx as a load-balancer using upstream server: upstream backend { ip_hash; server 1.2.3.4; server 1.2.3.5; server 1.2.3.6; } server { location / { proxy_pass …
Cyle
  • 145
  • 1
  • 8
3
votes
1 answer

Who should own the god process?

I have a stack running on ubuntu consisting of a Rack application written in Sinatra and GrapeAPI. The application stack includes Redis, Postgres, Nginx and unicorn. I want to use god to handle process monitoring. Currently deployment's are made…
Stewart
  • 151
  • 4
3
votes
3 answers

Is slow IO on my cloud server causing my slow server restart issues?

I'm running two servers on Rackspace cloud one for the web app and one for the db and redis instances. The web server has 1Gb of ram and single core. Nginx sits in front of unicorn which is running 2 workers. I also have a sidekiq instance running.…
toxaq
  • 131
  • 4
3
votes
1 answer

How to debug why my server has 3s delay on each request nginx/unicorn?

I am trying to debug why my server has 3 seconds delay on each request. These are my nginx and unicorn config files: https://gist.github.com/regedarek/de7f2e5cd1918b6224ac My server info: Welcome to Ubuntu 12.04.1 LTS (GNU/Linux 3.2.0-37-generic…
tomekfranek
  • 143
  • 6
3
votes
0 answers

Rails, Capistrano, Nginx, Unicorn - Application has been already initialized (RuntimeError)

Can anyone shed some light on what exactly this error refers to? I'm having trouble deploying new versions of the site. I, INFO -- : reloading config_file=[snip]/current/config/unicorn.rb I, INFO -- : Refreshing Gem list E, ERROR -- : error…
Andy Copley
  • 131
  • 5
3
votes
1 answer

Nginx + Unicorn

I am working on a migration from nginx + passenger to nginx + unicorn and I have reached a point where I am a bit stuck. When I attempt to view my test server, I get nothing but a 404 page. I am sure that I have something off in my vhost config but…
rottmanj
  • 213
  • 1
  • 3
  • 6
3
votes
1 answer

Nginx and Unicorn on separate machines

I've got a pretty standard Rails application running with Unicorn and Nginx all on one box. I'd like to split off the application itself and have Nginx on one machine and Unicorn (with the Rails app) on another machine. The idea here being that…
cmhobbs
  • 267
  • 1
  • 3
  • 11
3
votes
1 answer

Where does Varnish usually go in a Rails web stack?

I have a production Rails application deployed on Unicorn with nginx in front for static file serving. I now need some features of Varnish and I'm wondering how to introduce it. Some people put Varnish in front while others put nginx in front. I…
wormcontrol
  • 31
  • 1
  • 2
2
votes
1 answer

Rails - Nginx not caching images

I've got a VPS where I'm running my Rails app using Nginx and Unicorn. I was successful to add expires headers to JS and CSS files, however I cannot force Nginx to cache images as well (according to YSlow and Google PageSpeed Insights). Here's my…
kellins
  • 25
  • 4
2
votes
0 answers

Deploying sinatra app on rails app sub uri using( unicorn and nginx)

I have rails app running on unicorn+nginx. below is the nginx.conf and unicorn.rb configuration. nginx.conf upstream unicorn { server unix:/tmp/unicorn.todo.sock fail_timeout=0; } server{ listen 80 default deferred; #server_name localhost; …
2
votes
1 answer

IP spoofing attack errors after setting up a nodebalancer on Linode.com

I recently set up a NodeBalancer in front of a Rails 3.2.12 app. The app is served by nginx and Unicorn. All seems to work fine, but I get a lot of errors such as these that I didn't get when I only had 1 server. IP spoofing…
jlfenaux
  • 283
  • 1
  • 4
  • 8
1
2
3
8 9