我的网络服务器(nginx + mysql + php)目前约有500个在线客户端(谷歌分析)有一个小问题:只使用一两个MySQL线程,但有10个正在睡觉,网站很慢......看起来PHP正在为每个查询使用相同的线程。
mysql> SHOW PROCESSLIST; 返回:
+------+------+----------------+------+---------+------+----------------------+------------------------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+------+------+----------------+------+---------+------+----------------------+------------------------------------------------------------------------------------------------------+
| 1308 | root | localhost | NULL | Query | 0 | NULL | SHOW PROCESSLIST |
| 3748 | bs | localhost | bs | Sleep | 2 | | NULL |
| 3749 | bs | localhost | bs | Sleep | 2 | | NULL |
| 3753 | bs | localhost | bs | Sleep | 2 | | NULL |
| 3755 | bs | localhost | bs | Sleep | 1 | | NULL |
| 3756 | bs | localhost | bs | Sleep | 1 | | NULL |
| 3758 | bs | localhost | bs | Sleep | 1 | | NULL |
| 3759 | bs | localhost | bs | Sleep | 0 | | NULL |
| 3760 | bs | localhost | bs | Sleep | 0 | | NULL |
| 3761 | bs | localhost | bs | Query | 0 | Copying to tmp table | SELECT foo, foobar, bar FROM table_42 WHERE unicorn_horns=2 |
| 3762 | bs | localhost | bs | Query | 0 | Copying to tmp table | SELECT foo, foobar, bar FROM table_42 INNER JOIN trollolol ON trollolol.id=table42.unicorn WHERE uni |
+------+------+----------------+------+---------+------+----------------------+------------------------------------------------------------------------------------------------------+
11 rows in set (0.05 sec)
如何告诉MySQL(或PHP [PDO])使用2个以上的线程?