FATAL: sorry, too many clients already

1
We getting a number of our clients saying our application becomes slow & unresponsive. When checking the m2ee_log file I noticed a couple of errors at the times that they were complaining. The error is below.  Nov 19, 2018 4:16:15 PM org.postgresql.Driver connect SEVERE: Connection error:  org.postgresql.util.PSQLException: FATAL: sorry, too many clients already   This happens for a few seconds then seems to come right and they can use the application again. We have set ConnectionPoolingMaxActive to 150. Does the above error mean we need to increase that even more ? 
asked
1 answers
2

Hi Marc,

It looks like your Mendix Connection pool is configured to open 150 connections, but your PostgreSql server is probably configured to accept less connections. So it seems like you have conflicting settings.

Try increasing MaxConnections=150 in your postgresql.conf file.

However I doubt it needs to be set to 150, but the important things is that these settings need to either match, or your Postgres DB needs to accept more connections (MaxConnections) than the value set in your connection pool (ConnectionPoolingMaxActive).

Perhaps you actually need to decrease your ConnectionPoolingMaxActive to be more inline with the database's MaxConnections.

NB. You will need to restart your database if you change MaxConnections!

It might also be worth investigating if your connections are closing properly in which case you could do some investigation:

Run this SQL to see postgresql max connections allowed:

show max_connections;

Take a look at exactly who/what/when/where is holding open your connections:

SELECT * FROM pg_stat_activity;

The number of connections currently used is:

SELECT COUNT(*) from pg_stat_activity;

 

answered