DVA-C02Chapter 78 of 101Objective 1.3

RDS Proxy for Serverless Workloads

This chapter covers Amazon RDS Proxy, a fully managed database proxy service that sits between your serverless applications and RDS databases, designed to handle the unique challenges of serverless workloads like Lambda functions. For the DVA-C02 exam, understanding RDS Proxy is critical because it appears in questions about connection management, database scalability, and Lambda-RDS integration, typically accounting for 2–4% of exam questions. You must know when to use it, how it works under the hood, and how it compares to alternatives like direct connections or connection pooling libraries.

25 min read
Intermediate
Updated May 31, 2026

RDS Proxy as a Smart Connection Pool Manager

Imagine a busy customer support center with 10,000 agents (Lambda functions) and only 100 support representatives (database connections) who can actually handle calls. Without a proxy, every time an agent starts a call, they must wait for a rep to become free—but reps are slow to become available because each call setup takes 5 seconds (connection establishment overhead). If an agent disconnects mid-call (function crashes), the rep sits idle for 60 seconds (TCP timeout) before being reassigned. RDS Proxy is like a smart call router that maintains a pool of 100 pre-warmed reps. When an agent needs to talk, the router instantly assigns a waiting rep—no setup delay. If the agent hangs up unexpectedly, the router immediately reassigns the rep to the next agent in queue, without waiting for timeouts. The router also authenticates agents once using a master list (IAM authentication) and remembers their identity for subsequent calls, so agents don't need to re-authenticate each time. In cloud terms: the proxy maintains a warm pool of database connections, multiplexes them across many short-lived Lambda invocations, absorbs connection storms, and reduces latency by eliminating connection setup overhead. It also shields the database from Lambda's bursty, ephemeral nature—preventing connection exhaustion and RDS instance overload.

How It Actually Works

What is RDS Proxy and Why It Exists

Amazon RDS Proxy is a fully managed, highly available database proxy that sits between your application and an RDS database instance (or Aurora cluster). It was introduced specifically to address the connection management challenges that arise in serverless and event-driven architectures, particularly with AWS Lambda. In traditional applications, database connections are long-lived and reused across many requests. Lambda functions, however, are short-lived (maximum 15 minutes execution time, typically seconds) and stateless. Each invocation may open a new database connection, leading to connection exhaustion on the database server, which has a limited number of concurrent connections (e.g., MySQL default max_connections = 151 for db.t2.micro). RDS Proxy solves this by maintaining a pool of established connections to the database and multiplexing them across many client connections from Lambda functions.

How RDS Proxy Works Internally

RDS Proxy acts as a transparent proxy that intercepts client connections (typically from Lambda) and maps them to a smaller number of persistent connections to the RDS database. Here's the mechanism step by step:

1.

Authentication Handling: When a Lambda function attempts to connect to the database, it can use either IAM database authentication or native database credentials (username/password). RDS Proxy can authenticate the client using IAM credentials (preferred for Lambda) or by passing credentials stored in AWS Secrets Manager. The proxy validates the credentials against the database and establishes a session.

2.

Connection Multiplexing: Once authenticated, the proxy maps the client connection to an existing connection from its connection pool. The pool contains pre-warmed, authenticated connections to the database. The proxy maintains a mapping between the client session and the pooled connection. Multiple client connections can share the same pooled connection, but the proxy ensures that transactions are isolated—a client's transaction uses an exclusive pooled connection until the transaction completes or times out.

3.

Transaction Awareness: RDS Proxy is transaction-aware. It tracks whether a client is inside a transaction (BEGIN/COMMIT/ROLLBACK). If a client issues a BEGIN statement, the proxy pins that client to a specific pooled connection for the duration of the transaction. Once the transaction ends (COMMIT or ROLLBACK), the connection is returned to the pool and can be reused by other clients. This prevents transaction isolation violations.

4.

Connection Borrowing and Return: When a client sends a query, the proxy borrows a connection from the pool, executes the query, and returns the connection to the pool after the query completes (if no transaction is active). The pool size is configurable (MinConnectionPoolSize and MaxConnectionPoolSize), with defaults of 1 and 100 respectively.

5.

Idle Connection Management: The proxy monitors idle connections. If a pooled connection remains idle beyond the IdleTimeout (default 10 minutes), it is closed to free up database resources. The proxy also periodically health-checks connections.

6.

Failover Handling: For Multi-AZ RDS instances or Aurora clusters, RDS Proxy automatically handles failover. When the primary database fails, the proxy detects the failure and re-establishes the connection pool to the new primary. Client connections may see a brief interruption (typically under 30 seconds), but they do not need to reconnect manually—the proxy transparently redirects them.

Key Components, Values, Defaults, and Timers

Target Group: A logical grouping of database instances behind the proxy. You can have one or more target groups. Each target group points to a specific database (e.g., a specific RDS instance or Aurora cluster). The proxy routes connections to the targets in the target group based on the endpoint you use.

Connection Pool Maximum: Default 100, configurable up to 1000 (for some instance types). This is the maximum number of connections the proxy will maintain to the database. The actual number may be lower if the database's max_connections is lower.

MinConnectionPoolSize: Default 1. The minimum number of connections the proxy keeps open to the database even when idle.

MaxConnectionPoolSize: Default 100. The maximum number of connections the proxy will open to the database.

IdleTimeout: Default 600 seconds (10 minutes). Connections idle longer than this are closed.

BorrowTimeout: Default 0 (no timeout). Maximum time a client will wait to borrow a connection from the pool. If set to 0, it waits indefinitely.

MaxBorrowedConnections: Default 0 (unlimited). Maximum number of connections a single client can borrow simultaneously.

SessionPinningFilters: Controls when a client session is pinned to a specific database connection (e.g., when using SET statements or temporary tables). Common filter: "EXCLUDE_VARIABLE_SETS" to avoid pinning on SET statements.

IAM Authentication: RDS Proxy supports IAM database authentication for MySQL and PostgreSQL. This eliminates the need to store credentials in Lambda environment variables.

Secrets Manager Integration: If not using IAM, you can store database credentials in Secrets Manager and reference them in the proxy's target group configuration.

VPC: RDS Proxy must be deployed in the same VPC as the RDS instance. It requires a security group that allows inbound traffic from Lambda functions (or other clients) and outbound traffic to the database.

Configuration and Verification Commands

Creating an RDS Proxy via AWS CLI:

aws rds create-db-proxy \
    --db-proxy-name my-proxy \
    --engine-family MYSQL \
    --auth '[{"AuthScheme": "SECRETS", "SecretArn": "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-db-secret-abc123", "IAMAuth": "DISABLED"}]' \
    --role-arn arn:aws:iam::123456789012:role/rds-proxy-role \
    --vpc-subnet-ids subnet-123 subnet-456 \
    --vpc-security-group-ids sg-123

Registering a target (RDS instance) with the proxy:

aws rds register-db-proxy-targets \
    --db-proxy-name my-proxy \
    --target-group-name default \
    --db-instance-identifiers my-database-instance

Verifying proxy status:

aws rds describe-db-proxies --db-proxy-name my-proxy
aws rds describe-db-proxy-targets --db-proxy-name my-proxy --target-group-name default

Connecting from Lambda (Python with pymysql using IAM auth):

import pymysql
import sys
from urllib.parse import quote_plus

# Generate IAM auth token
rds_host = "my-proxy.proxy-xxxxxxxxxxxx.us-east-1.rds.amazonaws.com"
port = 3306
username = "lambda_user"
region = "us-east-1"

conn = pymysql.connect(
    host=rds_host,
    port=port,
    user=username,
    password=generate_auth_token(rds_host, port, username, region),
    database="mydb",
    ssl_ca='rds-combined-ca-bundle.pem'
)

Interaction with Related Technologies

Lambda: RDS Proxy is most commonly used with Lambda to manage connection storms. Lambda functions can open many connections in parallel, but the proxy limits the actual connections to the database. The proxy also handles Lambda's cold starts by having connections pre-warmed.

Secrets Manager: Used to store database credentials that the proxy uses to authenticate to the database. The proxy can automatically rotate secrets.

IAM: IAM database authentication allows Lambda to connect without storing passwords. The proxy validates the IAM token.

Aurora: RDS Proxy works with Aurora clusters, providing additional benefits like faster failover (sub-second to seconds) and connection pooling for Aurora Serverless v1.

VPC: RDS Proxy must be in the same VPC as the database. Lambda functions can connect to the proxy via VPC or VPC endpoints (for Lambda in a different VPC, use VPC peering or Transit Gateway).

CloudWatch: RDS Proxy publishes metrics like DatabaseConnections, ClientConnections, and QueryResponseTime to CloudWatch. You can also enable logging of SQL statements for debugging.

Performance Considerations

Latency: Adding a proxy adds a small latency overhead (typically <1 ms) per query due to proxying. However, this is offset by eliminating connection setup latency (which can be 100-200 ms per connection).

Connection Pool Sizing: Set MaxConnectionPoolSize based on the database's max_connections. A good rule of thumb is to set it to 80-90% of max_connections to leave headroom for direct connections (e.g., DBA tools).

BorrowTimeout: If Lambda functions experience timeouts waiting for a connection, consider increasing BorrowTimeout or scaling up the proxy (choose a larger instance class).

IdleTimeout: Lower IdleTimeout for cost savings if connections are not needed during idle periods, but keep it high enough to avoid frequent connection churn.

Security

Encryption: RDS Proxy enforces SSL/TLS for connections between the client and the proxy, and between the proxy and the database. You cannot disable SSL.

IAM Authentication: Recommended over Secrets Manager for Lambda because it eliminates credential storage. The proxy validates IAM tokens against the database.

VPC Security: The proxy's security group should allow inbound from Lambda security group on the database port (e.g., 3306 for MySQL). The database security group should allow inbound from the proxy's security group.

Limitations

Not for all workloads: RDS Proxy is not designed for long-lived connections or for workloads that can manage their own connection pooling (e.g., Java applications with HikariCP). It shines with short-lived, bursty connections from Lambda.

Supported engines: MySQL 5.7 and 8.0, PostgreSQL 10.16 and above, and Aurora MySQL/PostgreSQL. Not supported for SQL Server or Oracle.

No custom endpoints: The proxy provides a single endpoint per target group. You cannot route queries based on read/write splitting (use Aurora reader endpoints for that).

Transaction pinning: While the proxy is transaction-aware, certain statements (e.g., SET variables, temporary tables, LOCK TABLES) cause session pinning, which reduces multiplexing efficiency. Use SessionPinningFilters to minimize pinning.

Maximum connections: The proxy itself has a limit on client connections (default 1000, configurable up to 10,000 for larger instances). This is usually sufficient for Lambda.

Walk-Through

1

Lambda Invocation Triggers Database Connection

When a Lambda function is invoked (e.g., by API Gateway), it executes code that attempts to connect to the database. Instead of connecting directly to the RDS instance, the function connects to the RDS Proxy endpoint (e.g., myproxy.proxy-xxxx.us-east-1.rds.amazonaws.com:3306). The function may use IAM database authentication, generating an authentication token using the AWS SDK's generate_db_auth_token method. This token is valid for 15 minutes and includes the function's IAM role credentials. The connection request is made over SSL/TLS, as RDS Proxy requires encrypted connections.

2

RDS Proxy Authenticates the Client

RDS Proxy receives the connection request. If IAM authentication is enabled, the proxy validates the IAM token by calling the RDS API to verify the token's signature and expiry. It also checks that the IAM role has the necessary permissions (e.g., rds-db:connect) for the database user. If using Secrets Manager, the proxy retrieves the credentials from Secrets Manager and uses them to authenticate to the database. The proxy caches the authentication result for the duration of the client session (or up to the IAM token expiry).

3

Proxy Borrows a Connection from the Pool

After authentication, the proxy checks its connection pool for an available, idle connection to the target database. If a connection is available, the proxy maps the client session to that connection. If no connection is available, the proxy opens a new connection to the database, up to the MaxConnectionPoolSize. If the pool is at maximum and all connections are in use, the client request is queued up to the BorrowTimeout (default no timeout). The proxy maintains a mapping between the client session ID and the borrowed connection. This mapping is used for multiplexing.

4

SQL Query Execution Through the Proxy

The Lambda function sends SQL queries over the established session. The proxy forwards each query to the borrowed database connection. If the query is part of a transaction (i.e., preceded by BEGIN), the proxy pins the client session to that specific connection for the transaction's duration. This ensures that all statements in the transaction are executed on the same connection, preserving transactional consistency (e.g., SELECT...FOR UPDATE locks). Once the transaction ends (COMMIT/ROLLBACK), the connection is unpinned and returned to the pool. For non-transactional queries, the connection is returned immediately after the query completes.

5

Connection Return and Session Cleanup

After the Lambda function finishes its execution (or after a query completes), the client session may be closed (if the function terminates). The proxy detects the client disconnection and immediately returns the borrowed connection to the pool, making it available for other clients. If the client session had been pinned due to a transaction, the pin is released. The proxy also handles idle connections: if a pooled connection remains idle for longer than IdleTimeout (default 10 minutes), it is closed to conserve database resources. The proxy periodically health-checks connections by sending ping queries.

What This Looks Like on the Job

Enterprise Scenario 1: E-commerce Order Processing with Lambda

A large e-commerce platform processes orders using a Lambda function triggered by an SQS queue. Each order triggers a Lambda invocation that reads product inventory, updates stock, and creates an order record in an RDS MySQL database. During peak shopping seasons, the order rate can spike from 100 orders/second to 10,000 orders/second. Without RDS Proxy, each Lambda invocation would open a new database connection, quickly exhausting the database's max_connections (e.g., 1000 for db.r5.large). The database would reject new connections, causing order failures. By placing RDS Proxy in front, the connection pool is set to 800 (80% of max_connections). The proxy absorbs the burst: Lambda functions connect to the proxy (which has a higher client connection limit, e.g., 10,000), and the proxy multiplexes them over the 800 pooled connections. The result: zero connection exhaustion, lower latency (no connection setup overhead), and the database CPU remains stable. The team also enables IAM authentication, eliminating the need to store database passwords in Lambda environment variables.

Enterprise Scenario 2: Multi-AZ Failover for a Financial Application

A financial services company runs a critical application on Lambda that queries an RDS PostgreSQL Multi-AZ deployment. The database must be highly available. Without RDS Proxy, if the primary AZ fails, the database fails over to the standby, which takes 60-120 seconds. During that time, all Lambda functions with open connections would receive connection errors and need to reconnect—potentially losing in-flight transactions. With RDS Proxy, the proxy detects the failover within seconds (via DNS updates and health checks) and transparently re-establishes the connection pool to the new primary. Lambda functions that were waiting for a query result may see a brief pause (under 30 seconds), but they do not need to reconnect manually. The proxy also ensures that any uncommitted transactions are rolled back. The team configures the proxy with a small MinConnectionPoolSize (2) to keep a few connections warm across AZs.

Common Misconfiguration Pitfalls

Setting MaxConnectionPoolSize too high: If set above the database's max_connections, the proxy will attempt to open more connections than the database allows, causing 'too many connections' errors. Always leave headroom (e.g., 20%) for direct administrative connections.

Not enabling IAM authentication: Storing database passwords in Lambda environment variables increases security risk. Use IAM authentication with RDS Proxy for serverless workloads.

Ignoring session pinning: If Lambda functions use SET statements or temporary tables, they can cause session pinning, reducing multiplexing efficiency. Use SessionPinningFilters (e.g., EXCLUDE_VARIABLE_SETS) to avoid pinning on SET statements.

Incorrect security group rules: The proxy's security group must allow inbound from Lambda on the database port, and the database security group must allow inbound from the proxy's security group. Misconfigurations lead to connection timeouts.

How DVA-C02 Actually Tests This

DVA-C02 Exam Focus on RDS Proxy

The DVA-C02 exam tests RDS Proxy primarily in the context of Lambda and database scalability. Look for questions that describe a scenario where Lambda functions are overwhelming an RDS database with connections, or where connection latency is high. The exam expects you to recommend RDS Proxy as the solution.

Common Wrong Answers and Why

1.

"Use Amazon ElastiCache to cache database queries" – This is wrong because the problem is connection exhaustion, not query performance. ElastiCache reduces read load but does not reduce the number of connections. Candidates often confuse caching with connection pooling.

2.

"Increase the database instance size to allow more connections" – While increasing max_connections is a short-term fix, it does not address the root cause (short-lived connections from Lambda). RDS Proxy is the recommended solution because it provides connection pooling without modifying the database.

3.

"Use a connection pooling library like HikariCP in the Lambda code" – Connection pooling libraries are designed for long-lived applications, not Lambda. Lambda functions are stateless and short-lived; a connection pool in one invocation disappears when the function ends. RDS Proxy provides a server-side pool that persists across invocations.

4.

"Use Amazon DynamoDB instead of RDS" – While DynamoDB is serverless and handles connectionless access, not all applications can migrate to NoSQL. The exam expects you to optimize RDS usage with RDS Proxy, not switch databases.

Specific Numbers and Terms to Memorize

Default MaxConnectionPoolSize: 100 (configurable up to 1000)

Default MinConnectionPoolSize: 1

Default IdleTimeout: 10 minutes (600 seconds)

IAM token validity: 15 minutes

BorrowTimeout: default 0 (no timeout)

Supported engines: MySQL 5.7/8.0, PostgreSQL 10.16+, Aurora MySQL/PostgreSQL

SSL enforcement: Always required

VPC requirement: Must be in the same VPC as the database

Edge Cases the Exam Loves

Transaction pinning: If a Lambda function uses SET statements (e.g., SET time_zone='UTC'), the proxy may pin the session to a specific connection, reducing multiplexing. The exam may ask how to avoid this (use SessionPinningFilters).

Secrets Manager rotation: RDS Proxy can automatically rotate database credentials stored in Secrets Manager. The exam may test that the proxy uses the latest version of the secret.

Aurora Serverless v1: RDS Proxy is required for Aurora Serverless v1 to provide a stable endpoint and connection pooling. The exam may ask why you need a proxy for Aurora Serverless.

Failover behavior: During a failover, existing connections are dropped but the proxy reconnects transparently. The exam may ask about the impact on Lambda (brief errors, but automatic retry).

How to Eliminate Wrong Answers

If the question mentions "Lambda" and "database connections" and the answer choices include ElastiCache, DynamoDB, or scaling the instance, eliminate those unless the specific problem is read performance.

If the question mentions "connection pooling" and the answer is a client-side library, eliminate it because Lambda cannot maintain a pool across invocations.

If the question mentions "IAM authentication" and the answer includes storing passwords in environment variables, eliminate that option.

Always look for the answer that directly addresses the connection management problem without changing the database engine or adding unnecessary complexity.

Key Takeaways

RDS Proxy multiplexes many client connections from Lambda into a smaller pool of persistent database connections, preventing connection exhaustion.

Default MaxConnectionPoolSize is 100, configurable up to 1000; must be less than database's max_connections.

Default IdleTimeout is 10 minutes; idle connections are closed to free resources.

RDS Proxy enforces SSL/TLS for all connections; you cannot disable it.

IAM database authentication is recommended for Lambda; tokens are valid for 15 minutes.

RDS Proxy is required for Aurora Serverless v1 to provide a stable endpoint.

Session pinning occurs with transactions, SET statements, temporary tables; use SessionPinningFilters to avoid unnecessary pinning.

RDS Proxy supports MySQL 5.7/8.0, PostgreSQL 10.16+, and Aurora MySQL/PostgreSQL.

During failover, the proxy automatically reconnects to the new primary; client may see brief interruption but no manual reconnection needed.

RDS Proxy must be deployed in the same VPC as the RDS instance.

Easy to Mix Up

These come up on the exam all the time. Here's how to tell them apart.

RDS Proxy

Provides server-side connection pooling, multiplexing many client connections over few database connections.

Automatically handles failover for Multi-AZ and Aurora, transparently reconnecting clients.

Enforces SSL/TLS for all connections; supports IAM authentication for passwordless access.

Adds <1 ms latency per query but eliminates connection setup overhead (100-200 ms).

Requires additional configuration and cost (proxy instance charges).

Direct Connection to RDS

Each client opens a direct connection to the database, limited by max_connections.

Failover requires client-side reconnection logic; connections are lost during failover.

SSL is optional; credentials must be stored in the application (e.g., environment variables).

No proxy overhead, but connection setup latency incurred on each new connection.

Simpler architecture, no additional cost beyond the database.

Watch Out for These

Mistake

RDS Proxy is only useful for Lambda functions.

Correct

While RDS Proxy is designed for serverless workloads, it can also be used with EC2 instances, ECS tasks, or any application that opens many short-lived database connections. However, its primary use case on the exam is with Lambda.

Mistake

RDS Proxy eliminates the need for database connection limits.

Correct

RDS Proxy does not remove the database's max_connections limit. The proxy's connection pool size must be set lower than the database's max_connections to avoid errors. The proxy manages connections more efficiently but cannot exceed the database's hard limit.

Mistake

RDS Proxy supports all RDS engines.

Correct

RDS Proxy only supports MySQL, PostgreSQL, and Aurora variants of these engines. It does not support SQL Server, Oracle, or MariaDB (MariaDB is not supported as of 2025).

Mistake

RDS Proxy automatically scales the database.

Correct

RDS Proxy does not scale the database; it only manages connections. For read scaling, you still need read replicas. For write scaling, you need to scale the instance or use Aurora auto-scaling.

Mistake

RDS Proxy adds significant latency to every query.

Correct

RDS Proxy adds minimal latency (typically less than 1 ms) per query because it is a lightweight proxy. The overall latency is often reduced because connection setup time (100-200 ms) is eliminated.

Do You Actually Know This?

Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.

Frequently Asked Questions

Does RDS Proxy work with Lambda functions in a different VPC?

Yes, but the Lambda function must have VPC access to the proxy's VPC. You can use VPC peering, AWS Transit Gateway, or AWS PrivateLink to connect VPCs. Alternatively, you can place the Lambda function in the same VPC as the proxy. The exam often assumes Lambda and RDS Proxy are in the same VPC.

Can I use RDS Proxy with Amazon RDS for SQL Server?

No. RDS Proxy only supports MySQL, PostgreSQL, and Aurora (MySQL and PostgreSQL compatible). SQL Server and Oracle are not supported. For SQL Server, you would need to manage connection pooling manually or use other solutions.

How does RDS Proxy handle IAM authentication?

When a client connects, it provides an IAM authentication token generated by the AWS SDK (e.g., generate_db_auth_token). The proxy validates the token by calling the RDS API. The token includes the database user, host, port, and region. The proxy then authenticates to the database using the IAM token as the password. The database must be configured to use IAM authentication.

What happens to in-flight transactions during a failover?

RDS Proxy will automatically roll back any uncommitted transactions when it detects a failover. The client connection will be disconnected, and the client (e.g., Lambda) should retry the operation. The proxy re-establishes the connection pool to the new primary. There is no data loss beyond the uncommitted transaction.

Can I use RDS Proxy without Lambda?

Yes. RDS Proxy can be used with any application that opens many short-lived database connections, such as EC2 Auto Scaling groups or ECS tasks. However, the exam focuses on Lambda integration. Non-serverless applications may benefit from client-side connection pooling instead.

Does RDS Proxy support read/write splitting?

No. RDS Proxy does not perform read/write splitting. For read scaling, you must use Aurora reader endpoints or RDS read replicas. The proxy simply forwards all queries to the target group's primary instance. You can create multiple target groups pointing to different instances, but the application must choose the endpoint.

How much does RDS Proxy cost?

RDS Proxy charges per hour for the proxy instance and per GB of memory. The cost is typically lower than running a separate EC2 instance for connection pooling. Exact pricing varies by region and instance size. The exam does not test pricing details.

Terms Worth Knowing

Ready to put this to the test?

You've just covered RDS Proxy for Serverless Workloads — now see how well it sticks with free DVA-C02 practice questions. Full explanations included, no account needed.

Done with this chapter?