Postgres connection limits and what should rolconnlimit be set for default roles such as Postgres
I am locking down a Postgres 12 instance and can't find clear explanation of connection limits and rolconnlimit settings. First I have max_connection set to 100 but noticed that superuser_reserved_connections is set to 3. Does that mean that I have 97 connections effectively? That is not really an issue but I was curious.
The real stumper is how I set the role connection limits? Right now they are all -1(unlimited) but my guidance is that they must be set. Should I set a limit on connections for "postgres" and the other default roles such as pg_monitor, pg_read_all_stats, etc? If I do set them should they be set to something lower that max_connections? This database only has one user, which is an application account so I am assuming setting that to 100 will not be an issue?
Solution 1:
... max_connection set to 100 ... superuser_reserved_connections is set to 3. Does that mean that I have 97 connections effectively?
Short answer: Yes.
... role connection limits? Right now they are all -1 (unlimited) but my guidance is that they must be set.
"Guidance" from whom, exactly?
If someone is telling you that you must do something, then you would hope that they have at least some idea of how to do so and should be able to tell you this.
Of course, the first thing to do is to lock down your Test Postgres 12 instance and see what breaks. Making changes like this directly in Production would be madness.