I have spring-boot application running on Amazon-ECS. Instances of application are added on the fly using ECS. Now each application has HikariCP for connection-pool. So when I increase instances, connection-pool on each instance is not shared, & that will lead to problem. How do I handle this problem?
So far I've tried creating middle layer which will handle connection-pool & queries will go thru this, but then again this is just another bottleneck, how do I scale up this one? other part is using JNDI for same, which is some-what similar to previous solution. Or to adjust size of connection-pool on each cluster, but then when instances increase or decrease I'd like this size to adjust as well.
Honestly, I don't have any clue, how folks handle connection-pooling in clustered environment. What could be done to share connection pool, or the question is should be shared at all & if that's the case, how to put limit of number of connections, so that instances wont go thru starvation.