Rufus scheduler tasks on heroku running more often than scheduled - heroku

I have a Rails app running on heroku with Rufus Scheduler added on.
A 'once a day' task in the scheduler is running more often than once a day.
My guess would be something to do with the heroku app running on different dynos during the day, but I'm at a loss on how to confirm/fix the problem.
Has anyone else seen this/know of a solution?
Edit: I couldn't resolve the problem with the gem and have moved my app over to the heroku scheduler add on which does not experience this problem.

The Heroku scheduler isn't guaranteed, it's only a simple scheduling system designed to fill a gap. It's nothing to do with your application moving between dynos as it's a seperate management system spinning up one of processes.
If timeliness is essential to you, take a look at clockwork, which will let you configure all sorts of stuff, but also give you a bit more reliability (at the expense of having a clock process running).
If this won't do - simply rework your job so that it doesn't matter how often it runs.

Related

Wake app an asleep heroku app so the scheduler can run and let it sleep again

Heroku automatically sleeps the application afrer some time in the low price tiers which is a nice thing as it reduces the cost. But in a spring boot appllication the schedulers wont run when in sleep. Does heroru offer functionality to the wake-up the app so the schedulers will run?
Pinging every 30 minutes to have the app up and running does not suffice because the app will stay up even if it is idle. I would like to somehow wake up the app before a scheduler is about to run and then let is sleep back again if it is not used until a scheduler have to run again (or someone calls the api)
Your best bet is to move your job scheduling out of the main application. That way it doesn't have to be awake for jobs to run.
One way to do that is via the Heroku Scheduler:
Scheduler is a free add-on for running jobs on your app at scheduled time intervals, much like cron in a traditional server environment
Essentially, you can add jobs by providing a command to run and a frequency. The scheduler will kick the job off at the desired time.
Timing isn't guaranteed to be perfect, and very occasionally jobs may not run at all. But this is the most affordable option, and it has worked well for me in the past. For more precise and guaranteed timing you need to run at least one dyno continuously.

Heroku worker only app

If I have an app on Heroku that consists of one worker and one or no web dynos, will it run? I'm unsure if the absent or idling web dynos will cause the worker dyno not to run.
Heroku doesn't just run web dynos, in fact, it makes no assumptions at all with regards to the processes you're running. There's absolutely nothing wrong with launching a single worker process.
This is actually a common scenario for me to deploy single cron-like tasks to Heroku, I've written about it here http://blog.y3xz.com/blog/2012/11/16/deploying-periodical-tasks-on-heroku/
If you are looking for cron-like tasks for simple jobs (like I am), now you have another alternative: Heroku Scheduler. It is easy to configure in a dashboard.
Advantage:
No need to choose and learn a new scheduler library. Configure it in seconds.
Same way for different platforms: Python, Ruby, etc.
Save Dyno Hours for Free Plan user. Only the actual working time counts. Some scheduler library (like Rufus Scheduler) will keep running between launches (so that it does not rely on cron to work).
Disadvantage:
Trivial options. You can only choose among "Daily"/"Hourly"/"Every 10 minutes".
Conclusion: Best for basic use.

Heroku Iron.io worker vs cron vs worker dyno

My understanding is that Heroku charges Cron tasks based on the actual amount of time the task runs, using a dyno (based on: https://devcenter.heroku.com/articles/scheduler#dynohour-costs).
So, if I need a quick task to run every X minutes, I could use the cron addon to process it, instead of a worker dyno and I would be charged a fraction of the cost.
So, if everything above is true, what is the use of the Iron.io workers? They charge (about) the same as dynos from the cron jobs and they can't connect to the DB.
I have a feeling that I am missing something.
I'm under the impression that IronWorker can use the databases for Heroku. I may be mistaken about this, however.
I can't claim a great deal of experience with cron tasks on Heroku, so forgive me if I get its limitations wrong. However, I'm under the impression that scaling from one dyno to many dynos is a little bit of a process. Where IronWorker shines is really in enabling the number of worker servers to fluctuate based on demand--you have the capacity to scale at a moment's notice, but are only paying for the scale you're actually using.

Replacement for Heroku Scheduler

Heroku's Scheduler is great. For tasks running daily, hourly or at 10 minute intervals I think it's excellent and simple.
I have a (very fast running) process I want to run every 10 seconds. I have it set up as a rake task, how should I efficiently and simply set this up on the Heroku platform while minimising my dyno usage?
Thanks
Maybe these articles give hints even though they are for Java and Python:
https://devcenter.heroku.com/articles/scheduled-jobs-custom-clock-processes-java-quartz-rabbitmq
https://devcenter.heroku.com/articles/clock-processes-python

Heroku scheduling for one-off jobs

I want to schedule jobs to happen at a specific time and date but I'm getting confused by the wide range of options for doing so.
My requirements:
These are not recurring jobs, they only need to happen once at a specified date and time
I'm the only user of the app so don't need to deal with heavy traffic
I would like to minimise the cost of running this on Heroku, i.e. not paying idle dynos
Any tips on which combinations of gems etc. to use?
Have you looked into using https://github.com/bvandenbos/resque-scheduler? You'll need the Redis To Go addon on Heroku. This will cost you $36 a month because you'll need a scheduler process running alongside your web process. However, I've done this for free. See the README here: https://github.com/austinthecoder/pinger.
Good luck!
Due to Heroku Scheduler (default Heroku add-on) doesn't allow you to schedule your job as specific time. It is best to rely on a clock process to do the job. Gem such has Clockwork could be set up please see Heroku's Clockwork guide. You need to combine Clock with a background queuer such as resque or sidekiq. I highly recommend you go for sidekiq. Please bear in mind that both resque and sidekiq requires redis which is offered by redistogo add-on and it will cost you money to run it.

Resources