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)
CodePudding user response:
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.