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?
Right now both of your programs are using hours from a shared "hour pool" on your account. If you have uptime robot pinging your web dyno every 5 minutes (which means it doesn't have time to sleep and will be up for as long as uptime robot is running) and your worker dyno is up 24/7 you simply won't be able to run them together 24/7 for free, even if you have your credit card saved. A web dyno isn't idle if you're constantly pinging it.
I'm not entirely sure where you're getting the 250 hour figure from but if you want to run these side by side you have to let one of those dynos sleep. Right now that's not happening because of uptime robot so you're probably trying to use 1460/1000 dyno hours a month and getting your dynos shut down.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With