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
2
votes
1 answer

Unicorn error while hosting a Rails app with NGINX

All of a sudden my app stopped working and these are the last lines I am getting from unicorn.log unicorn worker[0] -D -c /home/deployer/apps/myapp/current/config/unicorn.rb -E production: relocation error: /lib/x86_64-linux-gnu/libssl.so.1.0.0:…
Darme
  • 253
  • 4
  • 11
2
votes
1 answer

How to properly secure Unicorn/RoR server on ubuntu? Or, harden RoR application stack?

I have few Unicorn servers running on Ubuntu 12.04 and I am looking to secure them against exploits which give remote shell. My main concern is, if it makes sense to deploy ModSecurity? Another thing is, that I have seen Unicorn typically runs from…
Andrew Smith
  • 1,123
  • 13
  • 23
2
votes
0 answers

How to load environment variables with Unicorn

I can't seem to get my server to load up the environment variables. In my ideal setup I would like 1 user (deployer) to serve multiple applications on a single server. Ubuntu 12.04, Nginx, Unicorn. In my apps I have a .env file that contain all the…
SpoBo
  • 121
  • 1
  • 4
2
votes
1 answer

Forward real IP through Haproxy => Nginx => Unicorn

How do I forward the real visitors ip adress to Unicorn? The current setup is: Haproxy => Nginx => Unicorn How can I forward the real IP address from Haproxy, to Nginx, to Unicorn? Currently it is always only 127.0.0.1 I read that the X headers…
Hendrik
  • 251
  • 1
  • 4
  • 11
2
votes
1 answer

Why is there a separate "unicorn_rails" for Rails apps?

According to the Unicorn docs, there are different binaries for Rails apps and other Rack apps: non-Rails Rack applications In APP_ROOT, run: unicorn for Rails applications (should work for all 1.2 or later versions) In RAILS_ROOT, run: …
Ben Lee
  • 626
  • 2
  • 9
  • 23
2
votes
3 answers

Rails + Nginx + Unicorn multiple apps

I get the server where is currently installed two apps and i need to add another one, here is my configs. nginx.conf user www-data www-data; worker_processes 4; pid /var/run/nginx.pid; events { worker_connections 768; # multi_accept…
2
votes
1 answer

Unicorn and copy_on_write_friendly?

While researching Unicorn configuration options I came across this snippet.. GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true If I undertand correctly, it optimizes how Unicorn handles memory allocation and resource…
Miko
  • 1,709
  • 4
  • 22
  • 28
2
votes
1 answer

configure www.example.com as example.com

I am using nginx as server backend sqlbuddy.example.com - for db manage (php-fpm) example.com - main site (unicorn) When I go to www.example.com I get sqlbuddy.example.com How do I get example.com at www.example.com sqlbuddy server { listen…
2
votes
1 answer

Apache / Unicorn: how to get Apache to serve static files

I'm following this tutorial to install apache + unicorn but it seems that apache doesn't serve any of the static files. Here's the config I came up with (take a look at Redirect all non-static requests to unicorn in particular):
Ramon Tayag
  • 469
  • 2
  • 7
  • 17
2
votes
1 answer

Trouble with nginx config and upstream servers

I'm trying to configure two applications to be served up by nginx. The first seems to be working fine and I duplicated the config for the second, however I'm having some problems. I'm running a Sinatra server backed with Unicorn using sockets to…
Samuel
  • 177
  • 2
  • 6
2
votes
1 answer

Nginx and unicorn

I have 2 aplications, each one running on unicorn. I'd like to use nginx as a front end for each of those application. For each nginx / unicorn pair I would then use a dedicated unix socket. To do so, do I need to have to instance of nginx or can I…
Luc
  • 518
  • 3
  • 5
  • 20
2
votes
1 answer

Monitoring slow nginx/unicorn requests

I'm currently using Nginx to proxy requests to a Unicorn server running a Sinatra application. The application only has a couple of routes defined, those of which make fairly simple (non costly) queries to a PostgreSQL database, and finally return…
injekt
  • 121
  • 1
  • 2
1
vote
1 answer

Block masking URL from nginx

Some bad person is masking my website with his domain www.baddomain.com. I would like to block it somehow from my nginx config file if that is possible. I tried to see from "baddomain.com" source code if he is using URL frame, but can't find one.…
1
vote
0 answers

Latest GitHub source not being deployed properly by Opsworks

I have an Opsworks Rails Layer (nginx/unicorn) instance that has been running for a while, and I have successfully deployed my rails app to it many times directly from GitHub. Yesterday, I started seeing a strange error where our latest code changes…
readyornot
  • 163
  • 2
  • 8
1
vote
0 answers

502 bad gateway errors after 68 concurrent users to website

I'm running into issues while doing some stress testing in jMeter. Essentially, we're hitting a hard limit of 68 concurrent users. As soon as the test ramps up to that number of users, we're getting 502 bad gateway errors. The thing that's…
Steve Wortham
  • 197
  • 1
  • 9
1 2
3
8 9