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
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).
ALB: What will happen if I have too many connections that have to wait for idle timeout elapsed to close?Accepted Answerasked 18 days ago
How can we find out when were the binary logs of a MySQL RDS instance created?asked 2 months ago
DB Connections Upper Limitasked 2 years ago
Use RDS Postgres Replicas as a clusterAccepted Answerasked 5 months ago
MySQL RDS instance stuck rebooting status over 4 hoursasked 2 years ago
Instability in RDS MySQL db after increasing storage spaceasked 2 years ago
AWS Application Load Balancer and Http2 Persistent Connections ("keep alive")Accepted Answerasked 6 months ago
Behavior with regard to open connections when changing rds proxy targetasked a month ago
RDS mysql releases the active as well as idle connectionsasked a month ago
MySQL RDS 'max_connections_per_hour' error, what are my options?asked a month ago