Skip to content

RDS Proxy PostgreSQL max connections

0

Hi,

I am trying to determine what is the maximum (client) connections that RDS PostgreSQL proxy supports. There is no setting nor formula to estimate or get this number. Other than percent setting for the DB side connections we are not seeing anything that can tell us.

Here is the problem that we are trying to solve, with traffic spikes and scaling of app instances we are running into issues with opening connections to the proxy. We've also attempted to scale up the DB, but that did not help.

Now I am trying to determine max connections on the proxy side through various tests without any serious load on the db itself. I've started with a separate cluster of size db.r6i.large and readwrite proxy. I've written a small Golang app with go routines that spin up and open given number connections to db, one worker, one connection. It can hold connection or open and close them. What I find is that db instance has max_connections of 1707 select setting::int max_conn from pg_settings where name=$$max_connections$$ and I am able to run up my bench test up to 1600 concurrent connections against db or cluster directly. This tells me that db is capable to supporting the max it has in the setting however once I test with same parameters against proxy I can safely get to only 1/2 of that. Our maxConnectionsPercent is set to 90.

I do see that connection pool to the db is smaller though however the whole premise behind proxy is to be able to scale up the connections by multiplexing without adding burden on the db itself. Once I breach this connection limit on the proxy I am seeing RST from the proxy

Can somebody enlighten me on why this is happening? I am not finding any docs that get into specifics on the limits or the scale for the client side, only the db side. Even if I assume that "max client connections" is == to the "max db connections" * maxConnectionsPercent I am still only getting only 1/2 of that. There is another post on max connections https://repost.aws/questions/QUfGBEjKUpSaeSpqqbynV3rw/inquiry-on-different-connection-pool-settings-for-rds-proxy-with-aurora-postgresql, but it focuses on the DB connections side NOT the client connections of the proxy.

Thank you!

2 Answers
0

Right now we are simply trying to measure how much does RDS Proxy will allow to scale connections, the result we are getting suggest that connecting directly to the database is more beneficial since connecting to proxy only gives us at most 1/2 of the max connections of the database.

I tried to increase IP address range in the subnet to /20 which did not have any affect. With MaxDatabaseConnectionsAllowed being 3,396 I would expect to be able to scale my client connections to at least that not a fraction of the max connections on the database side. Keep in mind that we are not pushing any work through the proxy or db. Tried this with and without running sql from the test.

answered a year ago
-1

The behavior you're experiencing with RDS PostgreSQL Proxy is related to how the proxy manages connections and its internal capacity. While there isn't a specific setting or formula to determine the exact maximum client connections that RDS PostgreSQL Proxy supports, there are several factors to consider:

  1. Connection Pooling: RDS Proxy performs connection pooling separately for the writer and reader instances of the associated RDS database. This optimization reduces the overhead of opening and closing connections.

  2. Connection Multiplexing: RDS Proxy uses connection multiplexing (or connection reuse) to perform multiple transactions using a single underlying database connection. This allows for more simultaneous connections to the proxy while maintaining a smaller number of actual connections to the DB instance.

  3. Automatic Capacity Adjustment: RDS Proxy automatically adjusts its capacity based on the size and number of DB instances registered with it. However, this adjustment isn't instantaneous and may require additional IP addresses to provision extra capacity.

  4. MaxConnectionsPercent: This setting (which you've set to 90%) determines the maximum number of connections that the proxy can establish with the target database as a percentage of the database's max_connections.

  5. Reserved Connections: RDS Proxy reserves a certain number of connections for active monitoring, fast failover, traffic routing, and internal operations. These reserved connections are not included in the available connections for your workload.

The fact that you're able to establish only about half the connections through the proxy compared to direct database connections could be due to a combination of these factors. The proxy needs to maintain some headroom for its operations and may not utilize the full 90% of max_connections that you've set.

To address your connection issues during traffic spikes:

  1. Ensure you have sufficient free IP addresses in your subnets. RDS Proxy needs these to scale up during high-demand periods.

  2. Consider increasing the size of your DB instance, as this can indirectly increase the proxy's capacity.

  3. Implement and optimize application-side connection pooling to reduce the frequency of new connection establishments.

  4. Monitor the MaxDatabaseConnectionsAllowed metric, which represents the number of connections available to serve the workload.

  5. For db.r6i.large instances, consider setting MaxConnectionsPercent to at least 20-30% to allow for sufficient headroom.

  6. Review proxy logs to check if connections are experiencing pinning, which can reduce multiplexing efficiency.

If you continue to experience issues, you may need to contact AWS support for a more detailed analysis of your specific setup and usage patterns. They may be able to provide more insight into any potential limitations or optimizations for your particular case.

Sources
RDS Proxy connection considerations - Amazon Relational Database Service
RDS Proxy concepts and terminology - Amazon Relational Database Service
Setting up network prerequisites for RDS Proxy - Amazon Relational Database Service
Modifying RDS Proxy - Amazon Relational Database Service

answered a year ago
EXPERT
reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.