defunkt/resque — pull request #793 by jamifsud (2013-01-17 21:45:43+00:00)
Title: Adding support for remote worker shutdown

Allows remote shutdown of workers when calling the worker's shutdown method.

Use case:
Instead of blindly killing workers, we'd like to intelligently shutdown workers that are sitting idle without forcing the job to terminate early. Our platform doesn't support SIGQUIT (Heroku), and the current workaround frequently kills jobs in flight when there are workers sitting idle. A remote shutdown allows us to kill off processes that are sitting idle (further saving money) and prevents jobs from being killed early when there are no idle workers by utilizing.

My intention with this pull request is to get a discussion started about the feature, beginning with a simple implementation. I'm unsure about polling Redis at each iteration of the work loop (though I can't see this as having too big of a performance impact), so I'd like to hear some opinions about that.

Some other implementations for your consideration:
- Adding a REMOTE_SHUTDOWN environment variable that enables this functionality so those that do not want it need not poll Redis each time
- I have a partial prototype of using an EventMachine based Redis implementation to use an async Redis PubSub strategy (triggers the shutdown method call on the actual worker instance when a remote worker instance has the shutdown method called), the issue with this is it requires a second Redis connection just for the shutdown signal.