I am working on a nestjs app that makes heavy use of task scheduling using the @nestjs/schedule package that integrates with the node-cron npm lib.
At the moment, the app has been in development for over 6 months and has over 30 cron tasks running in the background simultaneously. although most of them have distinct intervals, some crons have the same interval (e.g. runs EVERY 30 SECONDS). All cron tasks more or less follow the same behavior;
- send request to external APIs to get data.
- query mongo db to run some checks and update records accordingly.
some crons emit events to the client when certain condition is met by other cron tasks.
my question is: How can I measure the performance of the node process while running all these background tasks in my local development PC? and what effect it might have on requests that comes from the client? another point is: Is it possible to detect a memory leak before it happen?
basically I have concerns about the app performance and I want to try to prevent the problem before it happen. Thanks.