87

I've searched the web and browsed the RDS docs, yet I can't seem to find an open connection limit.

For what it's worth, I'm planning on using the new Postgres flavor of RDS, but I suppose an answer from the mySQL side of the house would be acceptable as well.

Thanks!

cs44
  • 1,210
  • 1
  • 9
  • 11

5 Answers5

118

If you setup a PostgreSQL RDS instance you can query for max_connections:

select * from pg_settings where name='max_connections';

max_connections is set to 5696.

sskates
  • 1,478
  • 1
  • 13
  • 12
  • 11
    Note that max_connections by default is parameterized on your instance's memory, so your number may be very different from 5696. – erjiang Apr 02 '15 at 16:06
  • Wow... This is great, had no idea I could query it like that... this will make my app far more efficient. – user1943442 Aug 20 '15 at 20:13
  • 3
    db.t2.small (2GiB Ram) has 198 connections – Peter Dietz Oct 11 '16 at 19:32
  • 4
    db.t2.medium (4GiB Ram) has 413 connections. The formula from the default parameter group is: max_connections = LEAST({DBInstanceClassMemory/9531392},5000), but I've yet to correctly plug anything into a calculator that matches. – Peter Dietz Oct 11 '16 at 22:50
  • @PeterDietz DBInstanceClassMemory is the amount of memory on the instance minus the memory for the service. You can work backwards with the available connections (3,936,464,896 bytes available). – Rudiger Jan 08 '18 at 02:21
  • 8
    `show max_connections;` query also does the same thing – bits Jan 25 '19 at 01:21
  • Note, I have found that the maximum connections physically possible can be much less than the allowed number of connections. I start running out of CPU at half of my allowed amount. – Neal Jun 26 '19 at 14:49
86

Simply with show max_connections;

You can modify this value on the Parameter Groups on the RDS console. The value of max_connections in the default postgres9.3 Parameter Group is {DBInstanceClassMemory/12582880}. In version 9.4 the default value is {DBInstanceClassMemory/31457280}.

Fernando Á.
  • 7,295
  • 7
  • 30
  • 32
  • Actually the default parameter group can not be modified so we should create a new parameter group , yes ? – Gentle Y Apr 23 '14 at 02:49
  • 5
    Right, you need to create a new Parameter Group, family of the default Parameter Group. Thanks for the hint! – Fernando Á. Apr 23 '14 at 13:45
  • 4
    Beware, this default setting may differ across postgres versions - in 9.4 the default value is `{DBInstanceClassMemory/31457280}`, which is less than half the connections of the previous default. – Brad Koch May 26 '15 at 17:34
  • 2
    With 1GB memory I should be getting 34 connections? My `show max_connections;` gives me 26. (1024*1024*1024)/31457280 = 34 Why amazon sets the value to this ratio? – Rafael Oliveira Jul 26 '16 at 22:23
  • 1
    Parameter Groups [documentation here](http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithParamGroups.html) – derekv Mar 29 '17 at 21:16
  • The formula is now `LEAST({DBInstanceClassMemory/9531392},5000)` in PostgreSQL 10.x and 11.x I can't find any information about why the upper limit is capped at 5000. It also appears that the `9531392` is lower than any of the previous values, implying that db connections have less memory overhead that they used to, also can't find any information on why that is the case. – Davos Apr 02 '20 at 04:29
13

Afaik the 'max_connections' returned above is actually the current value of max_connections as set in the ParameterGroup. I wanted to know how to dynamically figure out the max possible connections of a given Postgres instance in AWS, but for some reason could not even find an info sheet from AWS. However, I noticed that AWS console RDS section shows you a progress bar of your current connections vs total possible:

Snapshot from AWS console

Examining this in Google Chrome Tools, I have established that the blue part is 4 pixels wide, while the total width of the progress bar is 50 pixels, which means that my current 121 connections constitute roughly 8% of total, which gives an approximation of max possible connections for my db.r3.large instance at 1512.

astgtciv
  • 720
  • 5
  • 15
13

You can change the max_connections. Make a clone of the default parameters. Then change the value and save and set the instance group to the new options group and finally reboot your instance to make the setting take effect.

enter image description here

Matteo Alessani
  • 10,264
  • 4
  • 40
  • 57
David Dehghan
  • 22,159
  • 10
  • 107
  • 95
3

May be it's too late for answering, but you could find the Amazon Aurora RDS Postgresql connection limit here:

https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Managing.html#AuroraPostgreSQL.Managing.MaxConnections

Kunal Patil
  • 745
  • 1
  • 9
  • 18