What is the difference between connection pooling and max_connections? What is the difference between connection pooling and max_connections? database database

What is the difference between connection pooling and max_connections?


This below query will help you in finding out why you have so many connections

SELECT * FROM pg_stat_activity

In general how does the pool relate to max_connections?

Max value in your pool states the number of connections you have set in your pool. In postgresql, max_connections are the number of connections you have set in your database server. So each connection from your pool takes 1 value out from max_connections

Setting max_connections to 26 is pretty low, I suggest you to increase the set value.

Does each connection in the pool take 1 count out of the max_connections?

Yes, each connection takes out 1 count.

Does this mean that the pool max must always be smaller than the max_connections?

Yes, pool max must always be smaller than the max_connections

Would lowering the idle timeout on the pool help free connections faster?

Yeah, this definitely helps but not the perfect solution in this case.

Possible reasons!!

  1. Sometimes, there might be a connection leak, then database might get 10 times as many connections than usual.
  2. Also a common problem is something like that client side app crashing and leaving connections open and then opening new ones when it restarts

And also, did you check the superuser_reserved_connections variable value, please see this post, this might help you!!

Are you using Heroku for connection pooling?

A bit more detailed explanation here