0

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:

  1. 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.

  2. 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?

1
  • 1
    Most probably (1) no connection is created initially until you request one, and (2) idle connections are timed out. Commented Apr 3 at 23:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.