PHP?????????mysql_pconnect?????
???????????? ???????[ 2013/10/21 9:59:31 ] ????????
????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????????????????
??????

???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11