About recommended connection pool size

vm cpu: 15 prisma: 6.1.0 mysql 8.0.18 mysql max_connections: 4030 I have a question because I have a different opinion with my colleague regarding the connection_limit value. I am running 15 servers as a cluster with the express app on docker on a gcp vm instance. Docker is running on the gcp vm , and 15 (number of CPUs) express apps are running on docker. The questions are as follows: 1. What should be the connection_limit value of each express app? 2~3(15*2+1/15) or 31 2. Why is the number of CPUs relevant when calculating the number of connection pools? (My guess is to make as many connections as the CPU can handle?) 3. If one express server processes many query requests, a pool timeout is likely to occur if the connection_limit value is set to 2~3. In this case, should I increase the pool timeout value or connection_limit? (while testing)
1 Reply
Nurul
Nurul4d ago
Hey 👋 The number of CPUs is relevant when calculating the connection pool size because it's a way to estimate the potential concurrent workload your application can handle. More CPUs generally mean more potential for parallel processing, which could translate to more concurrent database queries. The formula mentioned here is for guidance, the optimal connection limits depends on your specific workload and performance requirements. If you are running into timeouts, I would recommend first trying to increase the connection_limit slightly (e.g., to 5 or 6) and observe the impact. If you still experience timeouts, you could then try increasing the pool_timeout. As your instance supports max_connections of 4030, I don't see any harm in increasing the limit

Did you find this page helpful?