Schedule Heroku tasks without using 2 additional dynos

95 views
Skip to first unread message

Ganesh Ranganathan

unread,
Dec 3, 2014, 4:54:55 AM12/3/14
to chen...@googlegroups.com, rubyonra...@googlegroups.com
Hi All,

I have a rails app hosted on Heroku which needs a regular task to run every 30 mintues. The task takes 5 minutes to complete

Previously I was using the gem resque and resque-scheduler for this. The problem however is that this requires 2 additional dynos, one for the scheduler and one for the worker task to run on.

Is there any way to achieve this just by using one dyno instead of two? Thanks in advance!

Thanks,
Ganesh

Ganesh Ranganathan

unread,
Dec 3, 2014, 5:21:33 AM12/3/14
to chen...@googlegroups.com, rubyonra...@googlegroups.com

On Wed, Dec 3, 2014 at 3:34 PM, Harisankar P S <mai...@hsps.in> wrote:

​You could use the sucker punch gem which does the background processing along with the rails process, so there shouldn't be the need to start another dyno. Not sure about if we can schedule it to start at a particular point of time.
 
 


​Thanks..this seems  to be a suitable gem for my purpose. The resque / resque-scheduler was overkill since it was costing $70 a month just to run simple scheduled tasks .
 
Btw, just curious. Cant we write cron jobs in heroku? Using something like the whenever gem.

​I am not sure conventional cron jobs can be made to work on heroku. There is no persistent file storage ​so even if the crontab file is edited, it wont reflect on any other dyno.

Thanks,
Ganesh

Harisankar P S

unread,
Dec 3, 2014, 5:48:33 AM12/3/14
to chen...@googlegroups.com, rubyonra...@googlegroups.com
On Wed, Dec 3, 2014 at 3:24 PM, Ganesh Ranganathan <ganesh.ran...@gmail.com> wrote:

Previously I was using the gem resque and resque-scheduler for this. The problem however is that this requires 2 additional dynos, one for the scheduler and one for the worker task to run on.

​You could use the sucker punch gem which does the background processing along with the rails process, so there shouldn't be the need to start another dyno. Not sure about if we can schedule it to start at a particular point of time.


Btw, just curious. Cant we write cron jobs in heroku? Using something like the whenever gem.

Cheers,

Harisankar P S

Harisankar P S

unread,
Dec 3, 2014, 7:13:19 AM12/3/14
to chen...@googlegroups.com, rubyonra...@googlegroups.com
On Wed, Dec 3, 2014 at 3:50 PM, Ganesh Ranganathan <ganesh.ran...@gmail.com> wrote:
​I am not sure conventional cron jobs can be made to work on heroku. There is no persistent file storage ​so even if the crontab file is edited, it wont reflect on any other dyno.


​Thats true, I did a google on running cron job in heroku it seems there is an addon called heroku scheduler[1] which would works like cron. But its run hours would cost as as your regular dyno run hours so it wouldn't be a cost efficient substitute. 


--

Ganesh Ranganathan

unread,
Dec 3, 2014, 12:56:33 PM12/3/14
to chen...@googlegroups.com, rubyonra...@googlegroups.com

On Wed, Dec 3, 2014 at 5:39 PM, Harisankar P S <mai...@hsps.in> wrote:
Thats true, I did a google on running cron job in heroku it seems there is an addon called heroku scheduler[1] which would works like cron. But its run hours would cost as as your regular dyno run hours so it wouldn't be a cost efficient substitute. 


​Ya it's wasteful to run a scheduler on it's own dyno all the time just to schedule 1/2 tasks.​ 

The sucker punch gem seems a good idea. I'll try it tonight..

Reply all
Reply to author
Forward
0 new messages