I have been using beaneater for background processing in my RoR application. I am using upstart to run beaneater in the background by running a rake task from my upstart srcipt.
exec bundle exec rake RAILS_ENV=production bs:beaneater
And my rake task is
task beaneater: :environment do
@beanstalk = BackgroundWorker.get_beanstalkd
asynch_tasks = BackgroundWorker.descendants
asynch_tasks.each do |aClass|
@beanstalk.jobs.register(aClass.tube_name) do |job|
aClass.process(job)
end
end
@beanstalk.jobs.process!
end
With this way I am able to run as many background processes as I want but
- I am unable to automatically spawn new processes, if needed.
- The rake task ran from upstart kills silently after burying the task in case of some error.
- An admin UI to see details would be a great.
Any recommendation on way to deploy beaneater on production.
Since
upstartis mentioned - you must be running some kind of bare metal or virtual server. Thus you're have a limited server capacity and there's little reason to have automatic scaling. There's some exact number of processes that is optimal for your server - you cannot go above that because there'll be stability and performance issues and no reason to go below.As for restarting failed processes - make sure you've configured
respawnFor more advanced options you can use
systemdthat comes as standard in many modern linuxes./etc/systemd/system/[email protected](note the@in filename, that's for scaling):Set to start at boot and run:
For resource monitoring you can make a separate "slice" with all these processes and see summary in
systemd-cgtopwith cpu/memory/network io etc.If you really need autoscaling - your path lies into cloud hosting, docker and kubernetes land, but it is much more complicated (and/or expensive, depending on provider).