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 at a glance
Key features include support for Rack, support for the Unix architecture, compatibility with Ruby 1.8 or higher, Rubinius support, process management, load balancing via the Linux kernel, supports both thread-safe or non-thread-safe apps, supports all Rack apps, as well as nginx-style binary upgrades that allow you to update the program and all of its components without losing clients.
Additionally, the software includes after_fork and before_fork hooks for apps that have special needs, especially when handling forked processes, copy-on-write compatible memory management for low RAM consumption, built-in Ruby DSL for configuring the server, ability to decode chunked transfers on-the-fly, and support for listening to multiple interfaces, including UNIX sockets.
Getting started with Unicorn
The software comprises of a C extension, which means that you will need to install a C compiler on your GNU/Linux system to compile it, besides the required Ruby development libraries and headers. It has been successfully tested with both 32-bit and 64-bit instruction set architectures.
To install the Unicorn HTTP server on your computer, open a terminal emulator and execute the “gem install unicorn” command, without quotes. The latest source code of the program can be cloned from Git or downloaded from Softpedia, free of charge, as a universal sources archive.
To use it for non-Rails Rack applications, you must use the ‘unicorn’ command, otherwise, make sure that you use the ‘unicorn_rails’ command for applications that have been written in Ruby on Rails. Detailed documentation can be found on the project’s homepage (see link below).