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
Hi there,
It seems that your database connections exceed the max_connections value and the reasons for that could be:
- Increases in the number of client/application connections to the DB instance, caused by an increased workload or table/row-level locking.
- 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.
- 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).
- 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/
Relevant questions
ALB: What will happen if I have too many connections that have to wait for idle timeout elapsed to close?
Accepted Answerasked 18 days agoHow can we find out when were the binary logs of a MySQL RDS instance created?
asked 2 months agoDB Connections Upper Limit
asked 2 years agoUse RDS Postgres Replicas as a cluster
Accepted Answerasked 5 months agoMySQL RDS instance stuck rebooting status over 4 hours
asked 2 years agoInstability in RDS MySQL db after increasing storage space
asked 2 years agoAWS Application Load Balancer and Http2 Persistent Connections ("keep alive")
Accepted Answerasked 6 months agoBehavior with regard to open connections when changing rds proxy target
asked a month agoRDS mysql releases the active as well as idle connections
asked a month agoMySQL RDS 'max_connections_per_hour' error, what are my options?
asked a month ago