Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of database proxy in AWS Lambda?

I'm working on AWS Lambda and I have integrated the SQL server using node.js. Here is its example. Now, my question is, what is the database proxy in AWS lambda and how I can get benefit from this?

Thanks

like image 511
Rafaqat Ali Avatar asked Dec 20 '19 20:12

Rafaqat Ali


People also ask

What is database proxy in AWS?

Amazon RDS Proxy gives you additional control over data security by giving you the choice to enforce IAM authentication for database access and avoid hard coding database credentials into application code. RDS Proxy also enables you to centrally manage database credentials using AWS Secrets Manager.

Can Lambda talk to database?

Yes. AWS Lambda can connect to an AWS hosted databases such as RDS or DynamoDB. AWS Lambda can also connect to external databases which are public or grant network access.


Video Answer


2 Answers

you have probably already read this:

RDS Proxy helps you manage a large number of connections from Lambda to an RDS database by establishing a warm connection pool to the database. Your Lambda functions can scale to meet your needs and use the RDS Proxy to serve multiple concurrent application requests. This reduces the CPU and Memory requirements for your database, and eliminates the need for connection management logic in your code.

If you have a single concurrent Lambda, then there is no benefit. However, many applications take advantage of the ability of Lambda to scale to 1000s or 10,000s of concurrent requests. Since Lambdas do not preserve state, these means establishment/maintenance of a DB connection for each of those 10,000s. This is inefficient, a pain to code, and can exceed the DBs ability to scale

So... from that same blog

Your Lambda functions interact with RDS Proxy instead of your database instance. It handles the connection pooling necessary for scaling many simultaneous connections created by concurrent Lambda functions. This allows your Lambda applications to reuse existing connections, rather than creating new connections for every function invocation.

The RDS Proxy scales automatically so that your database instance needs less memory and CPU resources for connection management. It also uses warm connection pools to increase performance. With RDS Proxy, you no longer need code that handles cleaning up idle connections and managing connection pools. Your function code is cleaner, simpler, and easier to maintain.

like image 122
Seth E Avatar answered Sep 28 '22 06:09

Seth E


The RDS proxy benefits will be clear in 2 scenarios:

  • High-concurrency lambdas to limit number of opened connections to the database. RDS Proxy will have limited connections opened regardless of how many concurrent lambdas exist

  • Low-latency applications to avoid DB connection time when lambda is just starting. RDS Proxy will keep a pool of warm connections to the database.

like image 31
iTech Avatar answered Sep 28 '22 06:09

iTech