How to configure Spring Boot HikariPool for use with AWS' RDS Proxy?
I've been trying to get our microservice setup to use the AWS RDS Proxy rather than connecting straight to the cluster for failover reasons. It connects just fine, but after it has been running for a while, there are errors that surface that end up having bad effects on any ongoing calls that happen at the time.
The error messages are:
- HikariPool-1 - Failed to validate connection org.postgresql.jdbc.PgConnection@11bc3390 (This connection has been closed.). Possibly consider using a shorter maxLifetime value.
- DataSource health check failed
The extra config properties I have setup in our application.properties file (besides username, password, url) are:
spring.datasource.hikari.maximum-pool-size=50
spring.datasource.hikari.minimum-idle=10
spring.datasource.hikari.max-lifetime=600000
spring.datasource.hikari.idle-timeout=180000
I have the RDS Proxy setup with pretty much the default settings for it.
Any ideas how to resolve these errors so that the connections from our microservice don't produce errors and cause any instability?
I don't have a fix. I guess you would need DEBUG logs or a debugger session to get to the core of this particular problem.
But I'm questioning the general architecture. Let's look at the docs:
Amazon RDS Proxy is a fully managed, highly available database proxy for Amazon Relational Database Service (RDS) that makes applications more scalable, more resilient to database failures, and more secure.
Your Amazon RDS Proxy instance maintains a pool of established connections to your RDS database instances, reducing the stress on database compute and memory resources that typically occurs when new connections are established.
https://aws.amazon.com/de/rds/proxy/
So the RDS Proxy is highly available and maintains a connection pool. This makes me wonder, why you also want a connection pool (Hikari) on the microservice itself. It seems redundant. You have effectively two fail-over mechanisms in your setup. I could imagine that this is the root of the problems you are describing.
I would suggest just using a simpler single-connection DataSource implementation to connect to the RDS Proxy.