Work out connection limit sizing instantly with clear inputs, formula shown and shareable results.
Total connection demand is instances multiplied by pool size, and it must stay below the server limit with headroom for administrative sessions, replication slots and monitoring. Each PostgreSQL connection is a backend process costing several megabytes, so raising max_connections trades memory that the buffer pool would use better — which is the argument for an external pooler such as PgBouncer.
Connection demand
requested = instances x pool size; server memory = requested x per-connection memory; utilisation = requested / max_connections
Each connection costs memory and adds scheduling overhead. Beyond a few hundred, throughput falls because the database spends more time context switching than executing queries.
Old and new instances briefly coexist, so peak connection demand can be double the steady state. Size the limit for that overlap, not the average.