ajit junghare
ajit junghare

Reputation: 165

How to share connection pool between Amazon-ECS instances

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.

Upvotes: 1

Views: 1493

Answers (1)

Geoffrey Wiseman
Geoffrey Wiseman

Reputation: 5637

The normal practice for connection pools with multiple instances is to manage each one independently.

When you have multiple instances of a Spring Boot application running on ECS, each one needs its own connection pool, and the parameters for that connection pool wouldn't normally vary when the number of instances goes up or down.

In essence, you decide how on the connection pooling parameters that are appropriate for each instance and you make sure the database server can handle the maximum number of connections you expect those settings to result in.

If you you have a lot of instances (EC2 instances, ECS tasks, etc) and this is creating a problem of too many connections, you can also consider Amazon RDS Proxy, although that involves another service and additional costs: https://aws.amazon.com/rds/proxy/

Upvotes: 1

Related Questions