0

Is it possible to have a unix socket across a network? Is it possible to have multiple application servers running unicorn use that same shared socket?

The setup I'd like to achieve would look like:

        nginx
          ↓
 Unicorn     Unicorn

nginx config:

upstream github {
    server unix:/shared/unicorn.sock;
}

Unicorn config (x2)

listen '/shared/unicorn.sock'

I know it's possible to do something like:

upstream unicorns {
  server 192.168.1.100:5000;
  server 192.168.1.101:5000;
}

However I think this is not ideal, because you don't get the benefit of Unicorn doing its own load balancing and you have to specify the ip addresses ahead of time.

A few years ago GitHub blogged about their Unicorn setup, where I think they are describing a similar setup, but it's not clear how to achieve this.

Ben
  • 1

1 Answers1

3

Unix sockets only work within that system. A socket across the network is called a TCP connection. The way to do this is have Unicorn listen on a TCP socket and configure nginx to use them as upstreams (as you mentioned). Unicorn doesn't have distributed load balancing; you need nginx to do the load balancing.

mgorven
  • 30,615
  • 7
  • 79
  • 122