Search code examples
javascriptnode.jssettimeout

What is the maximum number of setTimeout() methods that can be run at the same time usin Node.JS


I have a java script file which runs using nodeJS. I am using the setTimeout() method to create a sort of timer which will run some code after a user specified time. As multiple users will be using this code will there be a problem with running lets say 1000 setTimeout methods in parallel? Is there a maximum number that can run simultaneously or will it just make the program run slower the more I have?


Solution

  • There is no hard limit to how many setTimeouts you can have at once, it'll just use more memory the more you have, but if you have a lot and exact timing isn't important you may just want to load the events into an array and have a single setInterval going through the array and running them if the timeout finished.