Should I use RDS Proxy in my scenario?

,

We have dozens of applications all accessing a giant monolith of a MySQL RDS instance with a zillion schemas and tables in it. No replication at all due mostly to budget constraints and management not really wanting it.

All of our applications access this instance for heavy reads and writes with plain ol ADO.NET and MySQLConnector. The apps all run on EC2 instances. We have had trouble with maxing out connections and pooling issues in the past. A lot of the queries are old and crusty, and a lot of the code is as well… not terribly efficient and doing all sorts of loops slamming the database repeatedly in quick succession.

I honestly never read about RDS Proxy until recently… I have a few questions:

  1. Is this going to help at all in my scenario? It’s just one instance, with a lot of separate apps connecting to it at the same time.

  2. Are there any real downsides to using this versus just connecting directly to the DB in code?

  3. If I set up a proxy, will it interfere with how our apps access the DB today, or does this just create an additional way in?

  4. A problem I’ve always run into with the approach we have currently is that it’s difficult to determine metrics on which app might be acting up or abusing the database instance. Will RDS Proxy help me track this, or is there a better approach to help segment my app’s access to a single instance? Performance Insights is only useful to a certain extent, especially when a lot of code between apps will access the same data.

  1. Yes, if you’re not using a connection pool in your apps rdsproxy is a great idea. Even if you do have legacy connection pools it can still be useful.
  2. Not really besides another cost line item on the bill each month.
  3. You’ll have to point the apps at the proxy to begin utilizing it, not sure if ADO is able to do that in a zero downtime way
  4. It is going to be even less transparent who is connecting from what ip. Can you not create user_app_a_rw, user_app_a_ro, user_app_b_rw, user_app_b_ro, etc users and cut your apps over to using app specific users. This will also allow you to fine tune the grants over time so only apps that need to connect to specific schemas.

If this data is critical I’d continue to lean on your leadership to get this migrated over to aurora from vanilla rds so you have replicas.

Sorry this doesn’t address your question, but I just have to point it out. Your current database is a ticking time bomb. If mission critical data is stored there, your whole organization can blow up with it. I would strongly recommend replication, different DB users for different apps, and a comprehensive disaster recovery plan at the very least.

Yeah I’ve advised things like this but ultimately it’s not my call. We at least have weeks of automated rolling backups, good encryption, etc. I’ll continue moving them in the right direction with incremental changes and get there eventually…

Hopefully you performed a little C.Y.O. and got their refusal to your recommendations in writing. Once you ask someone to sign off on not doing something that could avoid a catastrophe, suddenly there might be some budget money appearing to do what you’re asking them to do.

Re #4 - you can create 21 endpoints for a proxy and each of these will have metrics.

for number 4, what you need is an APM like new relic, datadog, or something like query explorer RDS gives you. Those will tell you what queries are using up most of the DB time. From there you should be able to identify your application unless you’re reusing the query in a bunch of places.

Of course the paid tools like datadog or new relic provide a lot of insight without a lot of effort on your part. Just install the agents on the application side and instrument it. APM will give you a lot of insight. Especially if application side performance is critical.

Checking my privilege here but what kind of company has dozens of applications but can’t spare $100/month for some database redundancy?

From a performance standpoint there is little difference between using a direct connection and the rds proxy connection. For the most part, when you read and write data to the database, you roughly get the same amount of time spent doing either activity. At least this is what I have tested in past when my company moved over to using RDS Proxy.

The greatest benefit of using RDS Proxy is not having to manage the connection yourself through some use of an application pool connection or something similar. So, less things for you to manage over time.

Only disadvantage is the cost but what can you do? Everything is expensive with aws…

In all honesty, it’s probably 3-10K$ I’d wager as they say it’s giant database, so putting it multi-AZ would effectively double their cost. Assuming they’re not using RIs.

That being said, you’re completely right, especially since setting a DB to Multi-AZ is really not that hard, even splitting them off to different RDS databases isn’t that hard..

Sounds like OP needs to put a bit of pressure, or wait until it blows up I guess.

A very small company running on a tight budget with questionable (sloppy) business practices. As /u/shitwhore said, it’s an expensive database and it would double the cost which is likely the most prohibitive reason. I totally get the importance of it, I’m just working with what I’m given and I’m generally directed towards the performance and optimization side of things.

This is good to know, thank you!

Just wanted to say I appreciate the fact that you’re dealing with a suboptimal situation. This is life sometimes, at least for me.

Re #1 it’s been a while since I’ve used ADO.NET and have not specifically used MySqlConnector, but I would think and decent connector should have connection pooling on by default. You would have a pool per process and unique connection string

  1. Most likely, connection pooling is broken into two parts: Centralized (e.g. RDS Proxy) and Decentralized (e.g. JDBC). This can help return resources to the server by closing idle connections, they also help with connection churn if you’re opening and closing connections very frequently and see this causing performance impact.

  2. Proxies have dedicated connections to your server which are used from the pool. Only downside I’d see is if you ran out of connections and your pool was using what you need. It’s going to have a monitoring connection to your database so this is memory. I would say overall it’s best practice to use a connection pool whatever they may be.

  3. Your app needs to use the proxy endpoint. It won’t reboot your instance, Proxy is completely separate from your server and won’t restart when configuring.

  4. Each application should have an application user which identifies it. Then in Performance Insights you can see if a certain user is causing performance issues. Turn on connection logging to identify which server processes are causing issues and you can correlate it with a time when the process first started.

It also can affect the database system itself. We had terrible problems with performance with too many processes keeping their connections open on a postgres rds instance until we stood up RDS proxy, easiest and cheapest performance win ever.

Every connection consumes a bit of memory and can bring the whole thing to a crawl if it gets too much.

The biggest advantage of the proxy here is that it does the connection pooling all in one place rather than a hundred shitty programs.

I ended up making several “endpoints” for my proxy and I’m using them on different apps. I’m not sure how to see metrics per-endpoint… seems like they all share the whole proxy for metrics.

Wouldn’t I want pooling explicitly “off” on the connector’s side (or in the app in general) so that RDS Proxy can handle pooling itself?

No it would still be beneficial to have it on. You’ll get better network performance for your app and less latency

In cloudwatch under RDS there are proxy metrics- they are prefixed by name of endpoint