A Heroku WORKER Dyno (running in a python environment) goes to sleep after 30 mins. The worker executes a Celery Period task schedule to send emails to users.
Here the log showing the actual behaviour":
2019-05-29T12:49:02.273852+00:00 heroku[web.1]: Idling
2019-05-29T12:49:02.278946+00:00 heroku[web.1]: State changed from up to down
2019-05-29T12:49:02.288616+00:00 heroku[worker.1]: Idling
2019-05-29T12:49:02.306209+00:00 heroku[worker.1]: State changed from up to down
2019-05-29T12:49:03.087205+00:00 heroku[worker.1]: Stopping all processes with SIGTERM
2019-05-29T12:49:03.101608+00:00 app[worker.1]:
2019-05-29T12:49:03.101688+00:00 app[worker.1]: worker: Warm shutdown (MainProcess)
2019-05-29T12:49:03.185191+00:00 app[worker.1]: [2019-05-29 12:49:03,184: INFO/MainProcess] beat: Shutting down...
2019-05-29T12:49:03.297659+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2019-05-29T12:49:03.324661+00:00 app[web.1]: [2019-05-29 12:49:03 +0000] [4] [INFO] Handling signal: term
2019-05-29T12:49:03.326185+00:00 app[web.1]: [2019-05-29 12:49:03 +0000] [11] [INFO] Worker exiting (pid: 11)
2019-05-29T12:49:03.326993+00:00 app[web.1]: [2019-05-29 12:49:03 +0000] [10] [INFO] Worker exiting (pid: 10)
2019-05-29T12:49:03.626898+00:00 app[web.1]: [2019-05-29 12:49:03 +0000] [4] [INFO] Shutting down: Master
2019-05-29T12:49:03.758456+00:00 heroku[web.1]: Process exited with status 0
2019-05-29T12:49:04.817520+00:00 heroku[worker.1]: Process exited with status 0
As per research, I was of the understanding that the web
dyno goes to sleep, but the worker
dyno will not sleep.
https://devcenter.heroku.com/articles/free-dyno-hours :
Web:
If an app has a free web dyno, and that dyno receives no web traffic in a 30-minute period, it will sleep.
Warning NOTE: Worker dynos do not sleep, because they do not respond to web requests. Be mindful of this as they may run 24/7 and consume from your pool of hours.
I was expecting to have web on idle (av. 250 hours) + full 24/7 of the worker running Celery beat (750 hours) , to stay mainly withing the plan.
So far I have activated: https://uptimerobot.com/ with an period 5 minutes ping to the web dyno keep it running, but hours won't suffice for a full month. With this both dynos appear to stay awake.
Any ideas why this is happening? Potential solutions?