AWS RDS connection limits

193,239

Solution 1

AWS RDS max_connections limit variable is based on Instance type, so you can upgrade your RDS or make more replica.

The RDS types with max_connections limit:

  • 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 2540

Referring by max_connections at AWS RDS MySQL Instance Sizes in 2015

Update 2017-07

The current RDS MySQL max_connections setting is default by {DBInstanceClassMemory/12582880}, if you use t2.micro with 512MB RAM, the max_connections could be (512*1024*1024)/12582880 ~= 40, and so on.


Each Web server could have many connections to RDS, which depends on your SQL requests from Web server.

Solution 2

You can change the max_connections value by either updating the default parameter policy or create a new one - I'd suggest going with the latter.

  • Go to RDS
  • Parameter Groups
  • Create a new Parameter Group (AWS wil leave everything as default)
  • search for the max_connections value
  • Change the value to use
  • Go to RDS instance and modify
  • Select new Parameter group created and restart the instance or let AWS reboot it during next maintenance window

Hope this helps!

Solution 3

Actual info for Postgresql t3-instances (default.postgres10 parameter group):

  • db.t3.micro - 112 max_connections
  • db.t3.small - 225 max_connections
  • db.t3.medium - 450 max_connections
  • db.t3.large - 901 max_connections
  • db.t3.xlarge - 1802 max_connections
  • db.t3.2xlarge - 3604 max_connections

Its similar for default.postgres9 and default.postgres11

Solution 4

Login to your RDS instance (using a MySQL client) and run the following query:

SHOW VARIABLES LIKE 'max_connections';

Solution 5

The maximum number of simultaneous database connections varies by the DB engine type and the memory allocation for the DB instance class. The maximum number of connections is set in the parameter group associated with the DB instance, except for Microsoft SQL Server, where it is set in the server properties for the DB instance in SQL Server Managment Studio (SSMS).

MariaDB/MySQL {DBInstanceClassMemory/12582880}

Oracle LEAST({DBInstanceClassMemory/9868951}, 20000)

PostgreSQL LEAST({DBInstanceClassMemory/9531392}, 5000)

SQL Server 0 (unlimited)

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Limits.html#RDS_Limits.MaxConnections

Share:
193,239

Related videos on Youtube

Alaa Badran
Author by

Alaa Badran

Front-End engineer. PHP, Mysql, Javascript, XML, HTML, CSS, CSS3, HTML5, jQuery and AJAX.

Updated on September 18, 2022

Comments

  • Alaa Badran
    Alaa Badran over 1 year

    RDS server come up with 40 connection max, as in the following documentation
    I am using Magento 1.9, and at some points, i reach the max number then website is out of service.
    Do you have any recommended way to solve this issue?

    From my understanding, if i have 2 web servers connection to an RDS server.. then I should have 2 RDS connections, not more.

    • Admin
      Admin almost 7 years
      "From my understanding, if i have 2 web servers connection to an RDS server.. then I should have 2 RDS connections, not more." That's an incorrect understanding. It's typically 1 connection per worker process or thread.
    • Admin
      Admin almost 7 years
      Thanks @Michael-sqlbot .. Yes i misunderstand this, but i wanted to make sure. But, why when we have 40 connection coming to RDS it refuses other connection and be unreachable till other connections are closed?
    • Admin
      Admin almost 7 years
      That's by design, from the max_connections parameter. For most workloads, you should be able to safely increase it, because it's a safely conservative default value... but you'll want to investigate the cause of those spikes.
  • Alaa Badran
    Alaa Badran almost 7 years
    Thanks @jason I have the following information: When reaching 40 connection, RDS doesn't respond till other connections close. We have r3.xlarge RDS instance. Here is a screenshot of this: drive.google.com/file/d/0B-_uggt0MBYOZElEMEItWDIwUEk/… We have idle CPU with high number of connections
  • Alaa Badran
    Alaa Badran almost 7 years
    I know this, but when when reaching 40 connections, the server doesn't respond? Check this: drive.google.com/file/d/0B-_uggt0MBYOZElEMEItWDIwUEk/…
  • Nick Tsai
    Nick Tsai almost 7 years
    @AlaaBadran What is your instance type of the RDS?
  • Nick Tsai
    Nick Tsai almost 7 years
    I check the RDS Parameter Groups, the max_connections is default by {DBInstanceClassMemory/12582880}, so when you use t2.micro with 512MB RAM, the max_connections could be (512*1024*1024)/12582880 = 40.69 which could explain your 40 max connections.
  • Alaa Badran
    Alaa Badran almost 7 years
    We have r3.xlarge.
  • Nick Tsai
    Nick Tsai almost 7 years
    You could check the value by querying that RDS MySQL with command show variables like 'max_connections';.
  • carlin.scott
    carlin.scott over 6 years
    t2.micro has 1GB of RAM, not 512MB. docs.aws.amazon.com/AmazonRDS/latest/UserGuide/… the following query will tell you your max connections: SHOW max_connections;
  • Nick Tsai
    Nick Tsai over 6 years
    Yes, I just gave a example. t2.micro may only has 512MB before I remembered.
  • Orlando
    Orlando over 6 years
    This is connections, not other thing
  • bbozo
    bbozo about 6 years
    <3 this should be the accepted answer
  • Miguel Mota
    Miguel Mota about 6 years
    even though I set max_connections to 1000, rds still only allowed 100 max connections on a micro instance
  • backslashN
    backslashN about 5 years
    You can create a new parameter group and change the value of max_connections to the value you want. This will be the new connection limit for your RDS instance.
  • Gal Bracha
    Gal Bracha about 5 years
    The RDS max_connection has changed to DBInstanceClassMemory / 9531392 For example - for t2.medium with 4GB ram. It's - 4*1024*1024*1024/9531392 = 450
  • Dave Stein
    Dave Stein almost 5 years
    This answer holds up in 2019. You can always check yourself by doing SHOW VARIABLES WHERE Variable_name='max_connections'
  • Burak Kaymakci
    Burak Kaymakci almost 4 years
    @MiguelMota, that might be because of mysqlx_max_connections which is set to 100 and immutable. Correct me if I am wrong.