Magnetme/prerender-service — pull request #1 by TiddoLangerak (2014-12-03 17:01:17+00:00)
Title: Working load balancing

This implementation introduces proper load balancing between the PhantomJS workers. In one sentence load balancing between workers is no no longer done by the OS, but by the application itself (OS cannot detect which workers are already rendering, hence it balances wrongly).

Total changes:

- Workers no longer listen on an internet socket anymore, only the master thread does.
- Workers now listen on a unix socket (in `/tmp/prerender`)
- The master thread keeps track of which workers are available, and pipes the request to an available
worker.
- When no workers are available a 503 is returned directly

Improvements (not in this PR):
- Proper clean up on exit (socket files are currently not removed on program exit)
- Transform it into a fully distributed system (as in, all workers listen for connections and offload it to other workers only when they can't render themselves)

@Magnetme/developers - Ready for review!