0

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.

  • Did you go through the following link: https://stackoverflow.com/questions/41236543/jdbc-connection-pooling-in-a-tomcat-cluster-environment – Sagar Chilukuri Aug 07 '19 at 14:25
  • yup went thru it, not exactly solving my problem, The Module in question doesnt have diff database per user, but has multiple type of databases, so module could connect to mysql or mongo etc & will keep connection-pool for each datasource. So far I dunno if instances created on the fly in ECS will be in clustered mode & will share connection pool or not. Thats why the question, to see if there's any other alternative – ajit junghare Aug 07 '19 at 14:45

1 Answers1

0

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.

Geoffrey Wiseman
  • 5,459
  • 3
  • 34
  • 52