Regardless of whether one or multithreading is used, a union can be useful in allowing you to use open connections for reuse , rather than closing only to open another immediately after:
When you finish the connection, just call connection.release() and the connection will return to the pool, ready for others to reuse.
An additional benefit of multithreading is that the pool can also manage multiple concurrent connections:
Links are lazily created by the pool. If you configure the pool for up to 100 connections, but only ever use 5 at a time, only 5 connections will be made.
Although, to be clear, Node is multithreaded. It just uses a different model than it seems typical - a stream of "applications" that runs JavaScript and several "work" threads that handle basic asynchronous I / O.
source share