galaxyLogic 6 days ago

I think NodeJS apps typically rely on JavaScript event-loop instead of starting new processes all the time.

Spawning new processes for every user is possible but would probabaly be less scalable than even thread-switching.

2
jay-barronville 6 days ago

> I think NodeJS apps typically rely on JavaScript event-loop instead of starting new processes all the time.

> Spawning new processes for every user is possible but would probabaly be less scalable than even thread-switching.

I’d just like to note/clarify that there is, in fact, multi-threading happening under the hood when running Node.js. libuv, the underlying library used for creating and managing the event loops, also creates and maintains thread pools that are used for some concurrent and parallelizable tasks. The fact that JavaScript (V8 in the case of Node.js) and the main event loop are single-threaded doesn’t mean that multi-threading isn’t involved. This is a common source of confusion.

watermelon0 6 days ago

NodeJS apps usually use multiple processes, since JS event loop is limited to a single core. However, this means that you cannot share data and connection pools between them.