Running delayed jobs on Heroku for free

被刻印的时光 ゝ 提交于 2019-12-02 20:35:17

Splitting the process like that can incur problems - your best bet is it not try and get it 'free' but use something like http://hirefireapp.com/ which will start up a worker when there are jobs to perform reducing the cost significantly rather than running a worker 24x7.

Also note, Heroku will only ever autostart a 'web' process for you, starting other named processes is a manual task.

You can use Heroku Scheduler to run the jobs using the command

rake jobs:workoff

This way the jobs can run in your web dyno. According to Delayed_Job docs, this command will run all available jobs and exit.

You can configure the scheduler to run this command every 10 minutes for example, and it doesn't have sensible effect on the app's performance when no jobs are queued. Another good idea is to schedule it to run daily at a time with lower access rates.

Ideally there is no straight way to get this free, but you would find lots of workaround one can make to enjoy free background jobs. One of which is http://nofail.de/2011/07/heroku-cedar-background-jobs-for-free/

Also if you plan to use resque which is an excellent choice for background jobs you would need redis which comes free with nano version => https://addons.heroku.com/redistogo. https://devcenter.heroku.com/articles/queuing-ruby-resque

Simple solution is to buy a one dyno for the worker, whereas your web dyno would be free.

Let me if you need more help.

Thanks

Consider using the Workless gem: https://github.com/lostboy/workless

If you only have one web worker, Heroku will sleep it if it's inactive for an hour.

Also, Heroku will reboot all dynos at least once a day.

This makes it hard to do a within-ruby scheduler. It has to at least use persistent storage (e.g. database).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!