I noticed that PostgreSQL and MySQL have a 100 client connection limit by default. I'm wondering if I should turn this down since the webserver is on the same box and I only have about 20 PHP processes that would need to connect.
Should this setting match or exceed the number of processes that will try to connect?
In PostgreSQL (I don't know MySQL) there is max_connections property defined as:
Effective limit of client connections is defined as:
Default value for superuser_reserved_connections is 3.
You need to take some perspective view. Today let's say 40 max_connections is safe for you and it keeps some OS resources free (semamphores and shared memory as described in documentation), but tomorrow it might be not enough:
Let's calculate what profit you get:
Default value for autovacuum_max_workers is 3, so:
Each (Postgres) set has always 17 semaphores, so you have 68 semaphores safed:
For shared memory it's ~ 1 MiB (look at Table 17-2 for more details):
As you see it's not too much, so you can use default limit if you don't need such optimization.