Issue
I have a GET route within my app which simply initiates a load of scheduled tasks/cron jobs (using NPM modules such as node-cron and node-schedule)
I have recently implemented some logic to do some scraping of some player information from steam profiles inside repeatedRequests (main logic of my API). I have deployed my app to AWS which has allowed me to set up some basic monitoring and metrics of memory and CPU usage.
Looking at the MemoryUtilization chart
We can see that every 6 hours there is a constant incline in the memory usage of the app, which would point to the cron job I have recently introduced, am I not executing the cron job correctly? Could I handle promises better?
Is there also anything else inside repeatedRequests or other routes that I should or could be handling better which could be leading to memory leaks?
The larger requests made to the API start to slow down after about a day or a day and a half of the app starting from fresh, as you can see the memory usage has already increased 3 times since it started yesterday from 4% to 12% :O So I have to give it a manual reboot every week or it has crashed many times before too...
Thanks guys
Solution
It was a silly mistake, the cron job was set to start a new job every minute from every 6th, creating an infinite amount of new jobs that were stacking on each other
Since then the syntax has been changed to every 6th hour from
* */6 * * *
to 0 */6 * * *
and the memory usage is now sitting at a constant 7%, happy days!
Answered By - user2921885 Answer Checked By - Candace Johnson (WPSolving Volunteer)