Idle time before sleep

I was wondering about how long it takes for a service to fall asleep when not being used.

I wanted to store a little bit of state in my application, but to do that safely I need to know how long a service can be idle without falling asleep.


Related question:

Note @DanielX’s comment about looking into allowing writable files in the container. I think that would be super handy.

Keeping an app awake so that in-memory state persists seems like something you could never rely on at all. Not to mention it could be a big burden on HyperDev’s infrastructure. They probably save a lot by putting inactive apps to sleep.

I only need the state for about five minutes. If the timeout is greater than that then my solution should work.

Otherwise, I need some kind of remote timer callback API.

Containers sleep after 2 minutes of inactivity* and are destroyed after 15 minutes. For the most part the filesystem within each project is stateless, so you can’t write to it. The exception is ‘/tmp’, where you can but everything gets cleared after 15 minutes. Otherwise here’s a persistence example!/project/typhoon-pine as each hyperdev project gets a dynamodb.

*“Activity” is defined as active incoming connections (http or websocket). Activity does not affect the 15 minute timer, so please do not count on in-memory persistence.


Thanks, that’s very helpful!

One other question:
Not that I would do this (ಠ⌣ಠ), but what happens if every 90 seconds you make an http request from your application to it’s own URL? Will it just stay active forever?

Yeah, but we’d politely ask you to consider alternative ways around your issue. Every 15 minutes the container is completely removed no matter what. So whilst it would reawaken, its state would be lost anyway.

1 Like

I found out there are tiny redis instances that can be gotten for free, so that solved the state issue.

Do you know of any scheduling APIs? A way to have something call a webhook endpoint after some number of minutes, or every hour, etc?

Thanks again!

1 Like

I’ve used for a long time for this kind of thing, but I think they’ve removed their free tier. There’s a ton of other free web cron job services, but I don’t have any experience with them so can’t suggest a specific one. Zapier’s webhook and schedule zaps might also help:

It’s a feature in our backlog too, but not a high priority for now. Feel free to let us know if it should be.

1 Like

You’re the best! I was barking up the wrong search terms.

I am using for my cron jobs.
Easycron is free for “10 minutes" minimum interval which is worth a try.

Hi Gareth, is there a recommended way to run a bot using hyperdev or am I better off self hosting and runnin? This is the use-case I’ve come across for making keep-alive requests. Referring to slack specifically so I could use an outgoing webhook but that’s limited to specific channels and not currently channels-where-the-bot-is :confused:

For Slack specifically, there’s now no real issue with using HyperDev for them following the release of their Events API. Our Slack Bot examples use that too. It gives you access to almost all functionality, no keep-alive necessary, it pushes on event like a webhook.

Slack bot:!/project/curse-charger
Slash command:!/project/twisty-curtain

1 Like