The maximum number of connections available to an Amazon RDS PostgreSQL database instance depends on the instance class and the value set for the max_connections
parameter in the PostgreSQL configuration.
You can determine the maximum number of connections by using the following formula:
scss{DBInstanceClassMemory / (DBInstanceClassMemory - ( 10% * 1024))} * {DBInstanceClassMemory / (transaction_buffers + work_mem + maintenance_work_mem + max_locks_per_transaction)}
Where:
DBInstanceClassMemory
is the amount of memory available for the RDS instance class in bytes10% * 1024
represents the amount of memory reserved by PostgreSQLtransaction_buffers
,work_mem
,maintenance_work_mem
, andmax_locks_per_transaction
are PostgreSQL configuration parameters that affect memory usage.
You can obtain the values for these parameters by running the following SQL command on the PostgreSQL instance:
sqlSHOW shared_buffers;
SHOW work_mem;
SHOW maintenance_work_mem;
SHOW max_locks_per_transaction;
Note that the value for max_connections
cannot be greater than the number of available connections allowed by the RDS instance class.
The amount of memory needed for one connection in an Amazon RDS PostgreSQL instance depends on the workload of the application that is using the connection.
When a new connection is established, PostgreSQL allocates some memory for it, including memory for the client process, buffers for the query execution, and locks for synchronization purposes.
The amount of memory allocated for a new connection is affected by various configuration parameters such as work_mem
, shared_buffers
, and max_locks_per_transaction
, which define the size of workspaces, caches, and locks, respectively.
On average, each connection in a PostgreSQL instance may use anywhere from a few kilobytes to several megabytes of memory, depending on the complexity of the queries and the amount of data being processed.
It's important to monitor the memory usage of your PostgreSQL instance and adjust the configuration parameters as needed to ensure that there is enough memory available to handle the expected workload and the number of connections.