Introduction to Amazon RDS Proxy and It's use in Serverless Architecture

Last week Amazon announced General Availability of Amazon RDS Proxy, a fully managed and highly available database proxy for Amazon RDS Service. I was looking forward for its availability as there are many cases inserverless where it will benefit. One of the use case which I can relate to is scaling of lambda instances during a surge. This can bring your database down if you are not careful. Lets first understand how and then we can how RDS Proxy can help us in this. Consider the following serverless setup on one of your environment.


The above architecture has an API Gateway which is configured to trigger a Lambda Function to bring data back from RDS instance. At the first glance it all looks good. Isn't it? But lets imagine there is a sudden spike, and you receive lots of request to serve the data. In this requests will trigger multiple instances of a lambda function. Each lambda will make connection to database to fetch and serve the data. Once the connection limit is crossed, customers will start receiving 429 HTTP Response code i.e. Too Many Request. Ideally you should not use a combustible instance for RDS but in case if your are using it, you will loose all those CPU credits your system earned by just processing stuff in downtime. So what is the solution? This is where RDS Proxy comes in.

What is RDS Proxy?? RDS Proxy is a fully managed, highly available database proxy which will enable you to develop applications which are more resilient to database failures. RDS Proxy helps in three ways:

  • It creates and maintains a pool of connections which are shared across all the lambda functions using it.
  • It reduces database failover times and preserve application connection during the failovers
  • It has the ability to use IAM authentication to database and storing credentials in AWS Secrets Manager. One of the benefits of AWS Secrets Manager is auto rotation of credentials after set time.

Have a look at the following image. This shows how RDS Proxy fits into the above mentioned architecture.


The above image gives an idea how RDS Proxy can be utilised in the serverless environment. Let's list out the benefits in points:

  • Your Serverless Applications can scale efficiently as you will be re-using connection from a pool rather than make a new connection
  • The management of database credentials in now simplified as we will be using IAM Access via Secret Manager. You can also use IAM in RDS connection but it is kind of hard to setup properly.
  • As RDS proxy is fully managed, it can scale according to your application demand.
  • You can tell it to use an X percentage of the allowed connection in case you want to use multiple RDS Proxy with same database.

Have you make it till the end. Right!! now you maye be excited about it or not but before you start thinking about it let me first tell you about the supported database engines. As of writing of this article, RDS proxy supports Amazon Aurora with MySQL and PostgreSQL compatibility and RDS for MySQL and PostgreSQL.

Conclusion: I believe RDS proxy will be a must required connection manager for RDS for developing serverless applications. I still need to have a look at pricing and also would like to give it a spin to verify how effective it is. As of now, I am excited and would love to see more of these kind of stuff in serverless space.

I would love to hear what you think about this article and if there anything you would like me to cover in future. Drop me a line on @awsmag.