I'm working on a project which involves NodeJS, and using Typeorm to create a connection to a database. The Typeorm library utilizes a connection pool in order to create ten connections to a database by default for easy use. When I spin up my application, I was expecting to be able to see these TCP connections to the database by running the lsof command, like so: lsof -i -P -a | grep node. This doesn't seem to be the case though, as the connections do not show. When I start to put load on the server however, some connections do appear. My questions are:
If these connections keep appearing/disappearing under heavy load, does this mean that is it creating a new connection each time? I thought that the point of a connection pool was to have these open sockets so that we could select one to send a database request to at any moment, without having to open a new socket.
If indeed these sockets are already open as I expect, then why can't I see them with lsof? Do they need to be "assigned" in some sense in order to be able to see them?