Idle time before sleep


#1

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.

Thanks!


More information on technical limitations
#2

Related question:

http://support.hyperdev.com/t/storage-persistence-database-suggestions/121

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.


#3

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.


#4

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 https://hyperdev.com/#!/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.


#5

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?


#6

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.


#7

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!


#8

I’ve used https://www.setcronjob.com/ 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: https://zapier.com/app/explore.

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.


#9

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


#10

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


#11

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:


How to prevent app from sleeping?
#12

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: https://hyperdev.com/#!/project/curse-charger
Slash command: https://hyperdev.com/#!/project/twisty-curtain