1

My mean stack connected to mongodb atlas doesn't load after 30 mins of inactivity.

I created a mean stack app connected to atlas cluster and deployed it on render.com. But 30 mins after I stop working on my mean stack app, the home page takes at least a minute to load. Once it does load after a minute's delay, it doesn't cause a delay anymore, but only as long as I keep working on my app. 30 minutes of inactivity later, the homepage load gets delayed again.

My question is, why is my cluster going into this "sleep" mode just because I haven't used the app in the last 20-30 mins? Is there a setting that always keeps the atlas cluster up and running, without causing home page load delays? Am I missing some configuration?

vegetadeep
  • 21
  • 3
  • What is 'sleep mode' and how are you determining that is happening? – user20042973 May 28 '23 at 20:59
  • I am only using that phrase figuratively to indicate the state of the app. If you access the link for the first time, it will take at least a minute just for the home page to load. After that, for all subsequent accesses, it loads instantly. Then when I’m done using the app (& therefore the mongodb atlas) for like 30 mins, I again face the 1 minute delay when I access my app link. So, I am assuming this initial delay is probably because the db went inactive since the last time it was triggered? Is there is a setting that keeps the atlas cluster running 24*7, or a resume/pause button? – vegetadeep May 29 '23 at 13:24
  • My suggestion would be to do less assuming and to troubleshoot/debug/trace the app to find out where the latency is occurring. I'm not finding anything in the Atlas docs that suggests the database idles in some manner after 30 mins (though I do see a reference to 60 days). 30 mins does seem suspiciously like the default _session_ timeout, but again this is all just guessing and speculation. Let's find the problem first and then figure out what to do about it. – user20042973 May 29 '23 at 14:40
  • @user20042973 a user posted the reason for the delay. the problem is on render.com, it sleeps after 15 mins of inactivity. but thanks for your suggestions! – vegetadeep May 30 '23 at 23:32

1 Answers1

1

Render's free instances types automatically sleep after 15 minutes of activity: https://render.com/docs/free#free-web-services. You can upgrade to a $7/month instance to prevent sleeping.

anurag
  • 1,499
  • 14
  • 15
  • damn, didn't realize that, thanks so much for that information, man. I'll try to find a better production platform for my app. – vegetadeep May 30 '23 at 23:34