Question
We have data flowing into the Totum database through remouts in large volumes, and periodically the connection to the database is lost, or an error appears: "Database connection error. Please try again later: SQLSTATE08006 FATAL: remaining connection slots are reserved for non-replication superuser connections"
Answer
The issue is that too many remouts are being launched simultaneously. We need to increase the max_connections setting for the database.
By default, this value is set to 100 in PostgreSQL.
To increase it, you need to change the PostgreSQL configuration and restart the server.
You can find the path to the configuration file by executing the command:
su - postgres -c "psql -c 'SHOW config_file;'"
Open the configuration file at the specified path, for example:
nano /etc/postgresql/16/main/postgresql.conf
Look for the max_connections
parameter ā this is the number of simultaneous connections to the database. It is recommended to set it to twice the number of PHP-FPM workers.
Each connection consumes approximately 5Mb, so max_connections * 5 = RAM used for servicing connections. It should not exceed 25% of the system's total RAM.