By using AWS re:Post, you agree to the Terms of Use
/RDS mysql releases the active as well as idle connections/

RDS mysql releases the active as well as idle connections

0

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

1 Answers
0

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:

[1]https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/mysql_rds_kill.html

[2]https://aws.amazon.com/premiumsupport/knowledge-center/aurora-mysql-max-connection-errors/

answered 25 days 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