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?
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.
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 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
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.