Let's ask Callgrind
valgrind --tool=callgrind --dump-instr=yes --trace-jump=yes -v /usr/sbin/apache -X

Callgraph [pgssl.out]


So, let's turn off ssl in the postgresql.conf file and try again.

http_load
1000 fetches, 5 max parallel, 6e+06 bytes, in 9.19585 seconds
6000 mean bytes/connection
108.745 fetches/sec, 652468 bytes/sec
msecs/connect: 0.321531 mean, 23.129 max, 0.219 min
msecs/first-response: 44.8532 mean, 412.765 max, 8.065 min
HTTP response codes:
  code 200 -- 1000
Better, but another look at the callgraph shows we are still spending 10% of our time connecting to the database and more time tearing the connection back down.

Callgraph [pgconnect.out]


Turn on persistent connections
<?php
$config 
= array(
  
'db'      => 'pgsql',
  
'db_user' => 'nobody',
  
'db_pwd'  => 'foobar',
  
'db_host' => 'localhost',
  
'db_db'   => 'users',
  
'db_opts' => array(PDO::ERRMODE_EXCEPTION => true,
                     
PDO::ATTR_PERSISTENT => true)
);
?>
http_load
5000 fetches, 5 max parallel, 3e+07 bytes, in 14.7368 seconds
6000 mean bytes/connection
339.286 fetches/sec, 2.03572e+06 bytes/sec
msecs/connect: 0.404772 mean, 34.54 max, 0.168 min
msecs/first-response: 10.3008 mean, 94.533 max, 2.332 min
HTTP response codes:
  code 200 -- 5000
Ok, we are down to only needing 5 servers now.