How does connectionLimit work in node mysql? How does connectionLimit work in node mysql? express express

How does connectionLimit work in node mysql?


Is this like so or something else?

It's something else.

If connectionLimit is 10, the maximum number of connections that the driver will make to the database is 10.

Assuming the default driver options, if all of those connections are active (that is, they have been acquired from the pool to perform a query, but they haven't yet been released), then the next request for a connection (pool.getConnection()) will be queued: the driver will wait until one of the active connections gets released back into the pool. Your user will only notice a bit of a delay, but they won't get an error or no response; just a delayed response.

All this can be fine-tuned using the options documented here. For instance, if you prefer that instead of waiting, the driver returns an error, set waitForConnections : false.

Or, if you want the driver to return an error if, say, there are 25 requests queued to receive a connection, set queueLimit : 25.