Node JS MYSQL Create Pool not releasing DB connections once K8s PODs scaled down by HPA

15 Views Asked by At

We have a Node JS server which is deployed to K8 and HPA is configured for the deployment. This application is creating DB connection pool for MYSQL DB using below code.

const pool  = mysql.createPool({
  connectionLimit : dBConfig.connectionpoollimit,
  host            : dBConfig.host,
  port            : dBConfig.port,
  user            : dBConfig.username,
  password        : dBConfig.password,
  database        : dBConfig.database
});

I am observing that when the PODs are getting scaled down, the DB connections are not getting released, I checked the DB and there are lot of sleeping connections still lying on DB side.

Is there anything we can do to close these sleeping connections from applications side in case PODs shutsdown.

0

There are 0 best solutions below