????zend_hash_find??????????????????zend_hash_find(hash???key????key????value);????????value??????
????MySQL??wait_timeout??interactive_timeout
???????Keep-Alive?????MySQL???????????????mysql_pconnect??????????MySQL?????á????mysql_pconnect???????????????wait_timeout??interactive_timeout???????????????????????????????????????????????PHP????
<?php
$conn = mysql_pconnect("localhost"??"root"??"123456") or die("Can not connect to MySQL");
echo "MySQL????:". MySQL_thread_id($conn). "<br />";
echo "Apache?????". getmypid();
?>
???????????????y??????????????????????????棬???????????????????????????????MySQL??????????Apache???????????15?????????????棬??????????id????????????????μ?Apache???????????id???μ??hash key?????PHP???????????MySQL?????????????persistent list?????15????????Apache??????????MySQL??????????????MySQL??????????MySQL_thread_id??????????shell??????MySQL?????????'show processlist;'????????????
????[sql] view plaincopy
????mysql> show processlist;
????+-----+------+-----------+------+--------+-----+------+-----------------+
????| Id  | User | Host      | db   | Command| Time| State| Info            |
????+-----+------+-----------+------+--------+-----+------+-----------------+
????| 348 | root | localhost | NULL | Query  |    0| NULL | show processlist|
????| 349 | root | localhost | NULL | Sleep  |    2|      | NULL            |
????+-----+------+-----------+------+--------+-----+------+-----------------+
????????????????????????processlist?б??????????????????????Info???show processlist???У??????????shell???MySQL??????PHP????MySQL???????Id?349???У???????????????????????????Id=349??????????????????????????????????????????????MySQL_thread_id($conn)??????????????????????????????????????Command?к?Time?У?Command = Sleep??????????????????mysql_pconnect?????????sleep??Time??θ??????????????Sleep????????Sleep????????????????????????wait_timeout????interactive_timeout????????????????????????8С?????????????????????web?????????KeepAlive??????????processlist???????????????????Too many connections????????max_connectiosns???????????á???????????????????????????MySQL???????my.cnf??????????????????[MySQLd]??????????????????
????1 interactive_timeout = 60
????2 wait_timeout        = 30
???????????????MySQL??shell???MySQL???????show processlist?????????е????????????????????mysql_pconnect??PHP??棬?????MySQL??show processlist?????????????Commond?Sleep???????????show processlist(???????+enter??)???Time?е?仯2??5??10...14!???????Sleep?????kill?????????£??????30???????!??????????Apache keepalive??????????KeepAliveTimeOut??15???120(????????????)??????Apache??????????棬???????????show processlist??2..5..10..14??15??..20...26....28??29!????kill??????????wait_timeout????????????????????30??30????????????£??????Time????0?????????????????????interactive connection(MySQL shell???????????????interactive connection)???????????wait_timeout????????mysql_pconnect???4???????????
<?php
$conn = mysql_pconnect('localhost'??'root'??'123456'??MySQL_CLIENT_INTERACTIVE);
echo "MySQL????:".MySQL_thread_id($conn)."<br />";
echo "Apache?????:".getmypid();
?>
???????????棬MySQL??????show processlist?????Time > 30?????kill??>60???kill????????????MySQL_CLIENT_INTERACTIVE????MySQL???interactive connection????????PHP??MySQL??????120????δ??μ?????£??????????????MySQL??interactive_timeout?????????
???????
????PHP??mysql_pconnect?????Ч??????????Apache?????keep alive??????KeepAliveTimeOut??????????????????????????????????????????????keep alive?????壬??????????????????п????????????????????????????hold?socket???????????????cpu???????Apache??KeepAliveTimeOut????ú?MySQL??time out??????и???????????????????mysql_pconnectδ?????4???????????Apache??KeepAliveTimeOut???????????wait_timeoutС??????????mysql_pconnect?????????Apache??????MySQL?????á???????MySQL??wait_timeout????????????????£??????????????connection???MySQL??????????????????????Too many connections??????????KeepAliveTimeOut??????????????????????ò??Apache??KeepAliveTimeOu??????????MySQL??wait_timeout ???????????????????????????????keep alive???????????MySQL????????????????