Why am I getting a "Too Many Connections" error when connecting to my Amazon Aurora MySQL instance?

To Nha Notes | Jan. 17, 2023, 9:56 p.m.

Short description

If the client encounters a "Too Many Connections" error when you try to connect to an Amazon Aurora MySQL DB cluster or instance, this means that all available connections are in use by other clients. This is defined by the max_connections parameter.

You might see any of the following symptoms:

  • The DatabaseConnections metric in Amazon CloudWatch is close to or equal to the max_connections value for your Aurora MySQL DB instance.
  • The value for the max_connections parameter is higher than the available memory provisioned by the DB instance class for connections. Check for signs like a low FreeableMemory metric value in CloudWatch.
  • You get an ERROR 1040(): Too many connections error in the MySQL error log.

You can reach a max_connections value for the following reasons:

  • Sudden or gradual increase in the number of client/application connections to the DB instance. This has the following causes:
    • Increase in workload leading to increased connections.
    • Table/row level locking leading to an increase in the client/application connection.
  • Client/application not closing connections properly after the end of the operation.
  • Higher value for connection timeout parameters like wait_timeout and/or interactive_timeout that can lead to an increase in sleeping connections.
References

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