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
29
votes
5 answers

Need to increase nginx throughput to an upstream unix socket -- linux kernel tuning?

I am running an nginx server that acts as a proxy to an upstream unix socket, like this: upstream app_server { server unix:/tmp/app.sock fail_timeout=0; } server { listen ###.###.###.###; server_name whatever.server; …
Ben Lee
  • 626
  • 2
  • 9
  • 23
16
votes
2 answers

Optimal number of per CPU unicorn processes

We are running a Ruby on Rails web app under Unicorn. Our app is not strictly CPU bound (we have a dual Xeon E5645 system w/12 cores and a peak load average value is around 6). We started with 40 Unicorn workers initially but application memory…
Alex
  • 7,789
  • 4
  • 36
  • 51
8
votes
1 answer

Unicorn behind ELB, no nginx

If I understand Unicorn right (and in particular from their philosophy doc) it seems like Unicorn was really designed to operate behind a reverse proxy like nginx. My question is: can I drop nginx from my HTTP stack, considering we have an ELB at…
pedro
  • 181
  • 2
8
votes
2 answers

How to define different stop/restart signals with upstart

I am starting to convert all of our systems to using upstart to manage our various application processes. One thing that I am constantly missing is the ability to send a different signal to the process on stop or restart events. For instance, we…
localshred
  • 183
  • 1
  • 5
5
votes
1 answer

NGINX Unicorn 504 Gateway Time-out

I try all what I found in the Google by this question, but - nothing. It doesn't work anyway. My NGINX default: upstream app { server unix:/tmp/unicorn.rails.sock fail_timeout=0; } server { listen 80; root /home/rails/public; …
Orkhan
  • 59
  • 3
5
votes
1 answer

Unicorn workers timing out intermittently

I'm getting intermittent timeouts from unicorn workers for seemingly no reason, and I'd like some help to debug the actual problem. It's worse because it works about 10 - 20 requests then 1 will timeout, then another 10 - 20 requests and the same…
Bill Billingson
  • 153
  • 1
  • 5
5
votes
4 answers

Operation not permitted when starting Unicorn

I've created an nginx/unicorn/capistrato setup on Ubuntu (Amazon EC2) by following mostly this guide. I guess everything is set up like it should but when I start Unicorn I get (a LOT of) this error in the log: E, [2012-09-08T08:57:20.658092 #12356]…
fiskeben
  • 171
  • 1
  • 7
5
votes
3 answers

Using Upstart to manage Unicorn w/ rbenv + bundler binstubs w/ ruby-local-exec shebang

Alright, this is melting my brain. It might have something to do with the fact that I don't understand Upstart as well as I should. Sorry in advance for the long question. I'm trying to use Upstart to manage a Rails app's Unicorn master process.…
codykrieger
  • 187
  • 1
  • 7
4
votes
0 answers

Suddenly started experiencing enormous wait times before requests hit server

Our web app has been getting 20k-30k views a day, and steadily growing. About 4 days ago we suddenly started seeing wait times of 30-40 seconds before the HTML was even being delivered, on pages that had been rendering in 1 second even the day…
4
votes
0 answers

Gitlab not working because of unicorn

gitlab looks like it should be ok, but it is not - page returns always: 502 Whoops, GitLab is taking too much time to respond. Status: $ gitlab-ctl status run: gitlab-workhorse: (pid 10244) 718s; run: log: (pid 6421) 2922s run: logrotate: (pid…
Blaskovic
  • 61
  • 1
  • 5
4
votes
1 answer

Request timeout issue with nginx, unicorn and rails

I have an application in rails and it runs unicorn in production. There are some requests that take too long to process. I have configured the server to increase the timeout, so these request work correctly. The problem is that when the request…
Daniel Cukier
  • 823
  • 1
  • 10
  • 18
4
votes
1 answer

Nginx + unicorn + spdy + performance testing

I have a ruby on rails website that is hosted on unicorn webserver behind a nginx reverse proxy. I want to evaluate if using spdy will enhance my performance under this setup. Specifically, I need the directions on the following: does using…
tulio84z
  • 171
  • 4
4
votes
1 answer

Instances slow when connected to AWS load balancer

I have setup 5 t1.micro EC2's behind an AWS load balancer. All the instances slow down once they are connected to the LB. Eight out of 10 requests takes more than 30s even when I do the requests directly to the instances (bypassing LB). The CPU load…
4
votes
0 answers

Rails 4 Unicorn+Nginx on Ubuntu 13.04 VPS keeps crashing

I bought a years subscription at bluevm.com (found some coupon code, it was only about $15 for a whole year) to launch my first Rails Production server. I'm running Nginx with Unicorn and MySQL on Ubuntu 13.04. Once I got the initial server…
4
votes
1 answer

Rails when served by unicorn is generating the wrong fingerprint for precompiled assets

I have a production server with nginx -> unicorn -> rails. I precompile assets, which puts assets in public/assets with a fingerprint (hash) appended to the filename. However, when a web page is requested, references to application.css and…
Whit Kemmey
  • 141
  • 4
1
2 3
8 9