Do Web Services on a free tier go to sleep after some time inactive?

Hello!

I’m using Render to host a Docker-based web service (REST API). I notice that if I don’t use it for some time, the first request is really slow, but the following ones are ok.

So, do web services on a free tier go to sleep after some inactivity time?

Thanks!

Yes, after 15 minutes of inactivity as mentioned here.

1 Like

Oh, I missed that page! Thanks. :slightly_smiling_face:

But where is information to drop this limitation? What minimal tarif plan to use the app without the falling a sleep with this gap await 30sec?

I think they have a server-less option for free tier so you can call your service after every 14 min that will solve the cold-start problem in free tier otherwise move to paid version.

I used cron job to call the backend every 14 minutes so that it will not go to sleep. Here is how I did it.

can we please explain in detail how you can do this to make our server stay live
Because i am a beginner i dont know how to process with the above code you have provided

Create cron.js in your root directory and use the above code
Now you can import it to your main.js or index.js and then start the cron job by calling the start method on cron:

I Hope it resolves your issue

Thank you bro

I used cron-job.org to do this but in the billing section of Render dashboard, I noticed that free instance hours are increasing (Render allows 750 instance hours/month for the free tier plan).

Does the method you showed have any effect on the instance hours on Render?

Yes instance hours will increase since your instance is not going down.
An instance-hour is a unit of measurement used to calculate the cost of using a cloud computing service. It represents the amount of time that a computing instance runs for in a given hour.
Since how many hours you have in a month? (31 days * 24hrs = 744hrs per month) and they are providing you 750 hours/month.
It means your free instance hour will never become problem to you. So don’t worry :innocent:

Hi bro!

I am new to the concept of cron-jobs. I did just as you suggested to start the job using start method. But it is throwing a error stating “start is not a function”.

I have installed cron from npm using “npm i cron” command.
Created a cron.js file just like you. And in the index.js file I have called the start function after requiring it.

Can you help me with this issue?

It should work, if you need further help connect me on github: ‘tanishq-rocks’

try this while importing
in cron.js:
module.exports = { job: job }

in index.js:
const job = require(“./cron.js”).job

1 Like

In case you don’t want to monkey around with writing your own cron jobs, I built a small, free service to keep your free tier alive.

3 Likes

can you tell me how your service work?