RDS mysql releases the active as well as idle connections


We have our application running NODEjs as backend and connected to mysql database.

it creates many concurrent connections, so we made a limit of "max_connection" parameter to 5000, also for idle connection release we set "wait_timeout" and "interactive_timeout" to a specified value of 120 and 180 seconds respectively.

But when we using the application connections gets increases abruptly to a threshold value and then releasing the connections by taking all active as well as idle connections, which leads to connection error.

Please suggest why it is happening, it releases the active connections also along with the idle connections.

attaching the link of the screenshot image of connection behavior of mysql https://i.postimg.cc/TwSFKfTV/mysql-connection.png

asked 2 years ago1677 views
1 Answer

Hi there,

It seems that your database connections exceed the max_connections value and the reasons for that could be:

  1. Increases in the number of client/application connections to the DB instance, caused by an increased workload or table/row-level locking.
  2. Improperly closing a client/application connection after the end of an operation. When a server connection isn't properly closed, the client application opens up a new connection. Over time, these new server connections can cause your instance to exceed the max_connections parameter value. 
  • To list all active connections in your MySQL DB instance, use the SHOW FULL PROCESSLIST command.
  1. Sleeping connections (also known as inactive open connections) are caused by higher connection timeout parameters (such as wait_timeout or interactive_timeout). If you configure a connection limit that's too high, then you can end up with higher memory usage even if those connections aren’t used. As a result, when the application server tries to open all client connections to the database, these connections might be refused. 
  • To terminate a sleeping connection, use the mysql.rds_kill operation (see reference 1).
  1. It is best practice to only configure the active connections that are required for application performance. You might also consider upgrading to a larger Amazon RDS DB instance class. 
  • You can also consider increasing max_connections parameter value depending on the instance type that you are using and workload requirements (see reference 2).  References:



answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions