Website which is hosted on AWS not working due to limitation of database connections.

Issue:

Users are getting below error when they browse website which is hosted on AWS.

Could not connect to the database: SQLSTATE [HY000] [1040] too many connections.

Root Cause:

AWS RDS database has Database connection limitations.

Solution:

  1. Increase the database connection limit.
  2. Login to AWS management console.
  3. Go to RDS > Parameter groups > Select your database parameter group name
  4.  Select and edit max_connections parameter.
  5. Change the value according to your requirement.
  6. You can also upgrade your instance to next gen instance type based on your requirement.

Default Values for RDS instances:

t2.micro 66
t2.small 150
m3.medium 296
t2.medium 312
M3.large 609
t2.large 648
M4.large 648
M3.xlarge 1237
R3.large 1258
M4.xlarge 1320
M2.xlarge 1412
M3.2xlarge 2492
R3.xlarge 254