Fetching contributors…
Cannot retrieve contributors at this time
80 lines (56 sloc) 2.82 KB
# Einhorn: the language-independent shared socket manager
Let's say you have a server process which processes one request at a
time. Your site is becoming increasingly popular, and this one process
is no longer able to handle all of your inbound connections. However,
you notice that your box's load number is low.
So you start thinking about how to handle more requests. You could
rewrite your server to use threads, but threads are a pain to program
against (and maybe you're writing in Python or Ruby where you don't
have true threads anyway). You could rewrite your server to be
event-driven, but that'd require a ton of effort, and it wouldn't help
you go beyond one core. So instead, you decide to just run multiple
copies of your server process.
Enter Einhorn. Einhorn makes it easy to run (and keep alive) multiple
copies of a single long-lived process. If that process is a server
listening on some socket, Einhorn will open the socket in the master
process so that it's shared among the workers.
Einhorn is designed to be compatible with arbitrary languages and
frameworks, requiring minimal modification of your
application. Einhorn is simple to configure and run.
## Installation
Install from Rubygems as:
$ gem install einhorn
Or build from source by:
$ gem build einhorn.gemspec
And then install the built gem.
## Contributing
Contributions are definitely welcome. To contribute, just follow the
usual workflow:
1. Fork Einhorn
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Github pull request
## History
Einhorn came about when Stripe was investigating seamless code
upgrading solutions for our API worker processes. We really liked the
process model of [Unicorn](, but didn't
want to use its HTTP functionality. So Einhorn was born, providing the
master process functionality of Unicorn (and similar preforking
servers) to a wider array of applications.
See for more background.
Stripe currently uses Einhorn in production for a number of
services. Our Thin + EventMachine servers currently require patches to
both Thin and EventMachine (to support file-descriptor passing). You
can obtain these patches from our public forks of the
[projects]( Check out
`example/thin_example` for an example of running Thin under Einhorn.
## Compatibility
Einhorn was developed and tested under Ruby 1.8.7.
## About
Einhorn is a project of [Stripe](, led by [Greg
Brockman]( Feel free to get in touch at