2. Connection Management and Automatic Failover
One of the primary benefits of Amazon RDS Proxy is its ability to efficiently manage database connections and provide automatic, transparent failover for applications.
2.1. Connection Pooling and Multiplexing
RDS Proxy maintains a pool of established database connections. When an application requests a connection, the proxy reuses an existing connection if available, or establishes a new one. This reduces the overhead of establishing new connections and keeps the database server load low.
Multiplexing allows multiple client connections to share a smaller number of database connections. This is especially useful for applications that open and close connections frequently, such as serverless functions.
2.2. Automatic Failover and Application Resilience
In a multi-AZ deployment, if your primary database instance fails, RDS Proxy automatically routes connections to the standby instance. This failover process is typically much faster (often within seconds) than direct connections, as the application doesn't need to re-establish connections to a new endpoint.
Your application continues to connect to the proxy endpoint, which remains stable, ensuring application resilience without code changes.
// Example application connection string (pseudo-code)
const dbConfig = {
host: 'my-rds-proxy.proxy-xxxx.us-east-1.rds.amazonaws.com', // RDS Proxy endpoint
user: 'myuser',
password: 'mypassword', // Retrieved from Secrets Manager
database: 'mydatabase'
};
// Application logic uses dbConfig to connect to the proxy