Hello @raff ! Hope this message finds you well and that you’re having a good day.
The primary use case for RDS Proxy is when you have multiple apps using a single database. If I have three different apps each spinning up their own connections to a single database, it’s possible that bad connection handling logic could result in this overwhelming the resources of the database even if I have good application logic, monitoring and observability in place for the other two applications. By outsourcing how apps handle and create connections to RDS proxy you can get nice and predictable connection handling and do so effectively for multiple apps. It’s basically a managed service for the role that is served by a connection handler.
RDS Proxy does other things:
- Handles the connection pool for one or more application that are accessing shared database resources.
- Generally, helps you get more performance out of a database than you could by implementing a connection pool on your own from scratch.
- Can abstract away certain aspects of cluster topology from apps not equipped to do so by providing a single endpoint.
- Performs other useful functions like maintaining a bunch of active connections and recycling those, autoscaling etc. etc.
There are also some drawbacks:
It depends on the architecture you’re using and how your application is written on whether RDS Proxy makes sense to use. If it improves performance enough that it significantly lowers resources strain on the database, it might be cheaper to use RDS Proxy than not in some cases.
Having said that for our use case where we’re using Aurora Serverless v2 for our architecture I would say it doesn’t make sense to use RDS proxy. We already get a single endpoint and the version of the MySQL compatible aurora engine we’re using (for reference it’s version 3.08; which gets set as a variable first on line 65 and gets set as the engine for our database on line 734) is pretty advanced as is Aurora Serverless v2. It shouldn’t be that taxing on the database to spin up a bunch of connections quickly (it’s built for scale) and so if we use RDS proxy my prediction would be that we’d spend more money and get added latency on database calls (although I can be proved wrong in testing, I’d be willing to bet money I’m right on this).
In general, I’d recommend using Aurora Serverless v2 because 1/ it works for OpenMRS 2/ it’s performant and autoscales automatically 3/ most importantly, regarding cost, anything that’s using engine v3.07+ (we use v3.08) allows for scale to zero.
What this means is that if no one is using the database for more than 5 minutes (this can be set as a parameter if you’d prefer a different interval) the compute for the database will scale to zero and you’ll only pay for the data storage costs of the data written. The compute starts back up in seconds when someone goes to make a request after it’s been idle and scaled to zero.
I don’t think it’s possible to be more cost effective for OpenMRS while using RDS because any of the other options you can use will have some amount of fixed compute cost you’ll have to pay even when you’re not using the database. We don’t have that so if no one is using the database at 3 A.M. we won’t pay compute costs; they’ll be $0.
I also set up the database to have a reader serverless instance that scales along with the writer. In the event the primary serverless writer fails the serverless reader (which is already scaled up to where the writer was before it failed) will be promoted to become the new writer and then a new reader instance will be provisioned and scaled up automatically to where the new writer is and then in the event the writer failed again the process would repeat again. For reference this is implemented on line 746. The user shouldn’t notice a node failure. If the reader fails it’ll be replaced as well automatically; no need for manual intervention.
We also use multiple availability zones for the database as well. This means that there are multiple datacenters powering our database within a specific region so even if something happens with one datacenter, we will be resilient to that failure (same goes for compute with Fargate and file storage with EFS).
The other cool thing for Aurora Serverless is that it automates and manages the upgrades for the database engine for you. You can set it to do automatic minor version upgrades and even for major upgrades it’s pretty easy to do from the console. There’s documentation that outlines what the process looks like here: Upgrading the major version of an Amazon Aurora MySQL DB cluster - Amazon Aurora .
In general, I’ll try my best to make it to the platform calls. I’ll add it to my calendar. This week I won’t be able to make it but next week I should be able to.
It’s going to be hard for me to commit some sort of regular amount of time to coding. However, in general I’ll try to do my best to produce code example and answer questions asynchronously upon request.
In general (and this is true for anyone reading this thread as well) please don’t hesitate to reach out in the event you think I could be helpful with anything. I’m always happy to help :