SetTimeout performance in node?

For my webapp, I need you to have a lot of timeouts at any given moment, maybe around 10,000-100,000. I wonder how well this function scales.

I do not need it to be accurate, mostly accurate for 10-100 ms. Would it be better if one function were executed on an interval (say, to run every 50 ms) that checks the current datetime compared to the stored datetime and calls the function if so?

Does anyone have an idea about the basic setTimeout tool and can shed some light on how well en-masse can use it?

Other questions that I had: Does anyone know the limit of how many timeouts can be started immediately? In addition, with both approaches, I am concerned that there is not enough time to process each timeout per interval, and it gets โ€œbehindโ€ in terms of running the timeout function in time.

+4
source share

All Articles