Is there a way to force a Heroku Dyno to sleep?
Asked Answered
B

1

39

I'm trying to debug an API issue I have that occurs when my app tries to access a sleeping Heroku Dyno. The problem is it takes a while for a dyno to naturally sleep so it really slows down the debug process.

I know how to turn off a dyno but the bug I'm try to fix seems to happen when the app makes a request to a sleeping dyno that doesn't immediately respond, yet eventually responds.

Britska answered 19/3, 2015 at 22:23 Comment(2)
"I know how to turn off a dyno but the bug I'm try to fix seems to happen when the app makes a request to a sleeping dyno that doesn't immediately respond, yet eventually responds." that's normal. If a dyno is sleeping, it is not running and needs time to boot up. This usually takes 5-10 seconds.Suture
@JamesLu I know it's normal. The issue I had was in trying to replicate the scenario since there is no way to force the dyno back to sleep. You would have to just sit around waiting for it to go to sleep which takes a long time.Britska
B
56

I got the definitive answer from a Heroku engineer. It's no, you can't force a dyno to sleep.

Britska answered 21/3, 2015 at 18:49 Comment(9)
did they mention whether there any plans to change this?Educator
@EdSykes No, they did not mention any plans to change this. My feeling is that it is unlikely this would be added now especially since in their new dyno pricing structure you can get a cheap hobby dyno that never sleeps. Also, the new free dyno must sleep for 6 hours a day so you could probably setup a ping service (New Relic APN) to keep it up for 18 hours and then you have 6 hours of it being asleep to do your testing.Britska
For a server thats is only pinged 48 times a day its unfortunate you now need a hobby dyno for $7 per month just because my pings are in 25 min intervals. There is plenty of time to sleep if its not up to Heroku.Megasporophyll
@PolarBear Honestly I feel their new pricing structure is fair. For many years you could just ping the crap out of one of their free servers to keep it up and I'm sure they knew about this but were okay with it. Now you can still have a free server you just have to let it sleep only 6 hours, which for a free project is probably safe to do at night. And now it's actually cheaper to get a 24/7 dyno at $7 then in the previous pricing structure.Britska
@Britska I've paid the $7 its a fair price. However it's a bad sign either its a money grab or poor management. They offered a free tier which they could not actually offer for that price profitably long term. From that we can conclude that A: Pricing was not sustainable which means the new pricing is probably not as well and it will rise in the future again. B: They were purposefully using the free tier to get people to try the service and planned this pricing move along. Both options leave a bad taste in my mouth and are reasons to start looking else ware for a more honest hosting solution.Megasporophyll
@PolarBear I think I see it differently. First, they still have a free tier. The only thing different about it is that they are enforcing the sleeping policy whereas before it was assumed people would play nice and let it sleep. Likely it was all of the freeloaders that caused them to make the change. And be doing so they have now made all of the paid tiers cheaper. Also, for your 'B', this what all services do. It's called the Freemium model, everyone has it now. Students and hobbiests can keep using it for free but really it's for future paying customers to try things out.Britska
@Britska The thing is that its not about how much you sleep the Dyno. They have not given us control of when to sleep the free tier. So to use it for anything besides testing is impossible you cannot tell it when to turn off. I have asked Heroku support about this. I understand the freemium model but that is not what they had before. Before they had a low free tier that was viable for a basic website with very few visitors. Now that is not possible so it is a Freemium service. They could have just enforced website hits per month or pings to make sure people were not abusing the service.Megasporophyll
I really don't like that they are trying to put the blame for this change on those who abused the Free tier. There are ways they could easily have stopped that abuse. This was planned for other reasons and they should just own the new pricing model and not say its our users fault we had to change it.Megasporophyll
How can anyone be mad about this? It's a fantastic service that you can operate for free, with caveats here and there. It's costing them money to give you free stuff; let them regulate how that free stuff is used, or pony up a few measly bucks. Everything in the world that exists required some amount of time and/or resources to make happen. Nothing is truly free; own it, pay it, be happy it's available at all.Artima

© 2022 - 2024 — McMap. All rights reserved.