mysql pconnect voes
| From: | jani mikkonen | Date: | Thu, 29 Nov 2001 08:27:20 +0000 |
| Subject: | mysql pconnect voes | ||
| Groups: | php.db php.general | ||
| Request: | Send a blank email to php-db+get-14683@lists.php.net to get a copy of this message | ||
Im managing a really crowded webservers. We have article system implemented
in php and backend db is mysql (not my first choise but hey, it does the
job)
Few version numbers:
PHP: 4.0.6 (Self compiled, w/ gcc in solaris8)
Mysql: 3.23.24 (Self compiled, w/ gcc in solaris8, ok, not the latest
stable but i dont think this is the real problem)
Apache: 1.3.22 (Self compiled w/ no other 3rd party modules besides php)
Our code uses pconnects throuout the whole site. Website is ran from 6
different sparc solaris boxes and one db box is serving them all. This
mysql has connection limit in 750 and all apache servers have following
three lines in their php.ini:
mysql.allow_persistent=On
mysql.max_persistent=50
mysql.max_links=70
Afaik (mysql.max_links - mysql.max_persistent) is how many nonpersistent
connection i can have (in this case, 20 per server). And i have 50
persistent. So, i have 6 servers with 50 persistent connections and
all pconnects are to same db with same account so there should be
available connections in the pool.
BUT. After 5 minutes or less (depending on the time/load) all connections
hang because php has used *all* available connections in mysql server
(which is 750). I cant image how this is possible. I have 70 connections
per server, 6 servers, thats 420 max connectios, that should leave with
with 330 spare ones but now. Everything is used up. Even if i would have
50+70 connections (120*6=720) per server, i would still have 30 spare ...
So, only solution for me is to set mysql connection timeouts to really
low (20 seconds, when default value is 8 hours). And this leads me to
*huge* error logs. For example, i just deleted few months old mysql log
which was over 2 gigs.
I have few ideas. Are these limits in php, per process or per whole
process tree ? Sounds to me that they are per process or pconnect still
has really nasty bugs in it.