0

Would a Nodejs instance scale with enormous usage of setInterval and setTimeout APIs? I have a use case where my NodeJS server needs to keep a timer for some activity going on at the client and if the total time lapsed is above a configurable time, then we push a message. From my understanding, any asynchronous task like ( timers or xhr ) are taken care by a background thread and once the event is done, then it gets pushed to main JS thread. If I create, for instance, 1000 timers at once, would that make my node process slow assuming many threads would be created the NodeJS

pratyush jha
  • 143
  • 1
  • 2
  • 7
  • Probably find most of your answer here: [How many concurrent setTimeouts before performance issues?](https://stackoverflow.com/questions/38276583/how-many-concurrent-settimeouts-before-performance-issues/38277310#38277310). Your assumption that each timer is a new thread is not correct. – jfriend00 May 25 '17 at 05:02
  • Probably best to implement a Promise based timer, which are non-blocking async threads. – jtrdev May 25 '17 at 05:03
  • @teachtyler timers are non blocking async by nature in JavaScript, right? – pratyush jha May 25 '17 at 05:05
  • Also you can check into cron npm, https://www.npmjs.com/package/cron – chetan mekha May 25 '17 at 05:10
  • 1
    http://latentflip.com/loupe/ Test the event loop – jtrdev May 25 '17 at 05:13

0 Answers0