为什么我的Drupal间歇性地缓慢? Stracing显示了很多重复的sendto调用

时间:2015-03-04 19:42:49

标签: php performance drupal

我管理的其中一个Drupal网站偶尔会加载很慢。如果我在发生这种情况时使用PHP-FPM,我会看到很多poll / recvfrom / sendto系统调用看似相同的内容:

[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24589, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "\207\2\0\0\3INSERT INTO menu_router\n   "..., 651, MSG_DONTWAIT, NULL, 0) = 651
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24578, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "\\\2\0\0\3INSERT INTO menu_router\n   "..., 608, MSG_DONTWAIT, NULL, 0) = 608
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24567, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "T\2\0\0\3INSERT INTO menu_router\n   "..., 600, MSG_DONTWAIT, NULL, 0) = 600
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24556, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "2\2\0\0\3INSERT INTO menu_router\n   "..., 566, MSG_DONTWAIT, NULL, 0) = 566
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24545, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "\37\2\0\0\3INSERT INTO menu_router\n   "..., 547, MSG_DONTWAIT, NULL, 0) = 547
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24534, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "\r\2\0\0\3INSERT INTO menu_router\n   "..., 529, MSG_DONTWAIT, NULL, 0) = 529
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24523, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "B\2\0\0\3INSERT INTO menu_router\n   "..., 582, MSG_DONTWAIT, NULL, 0) = 582
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24512, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, ":\2\0\0\3INSERT INTO menu_router\n   "..., 574, MSG_DONTWAIT, NULL, 0) = 574
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24501, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "(\2\0\0\3INSERT INTO menu_router\n   "..., 556, MSG_DONTWAIT, NULL, 0) = 556
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24490, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "4\2\0\0\3INSERT INTO menu_router\n   "..., 568, MSG_DONTWAIT, NULL, 0) = 568
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24479, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "(\2\0\0\3INSERT INTO menu_router\n   "..., 556, MSG_DONTWAIT, NULL, 0) = 556
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24468, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, " \2\0\0\3INSERT INTO menu_router\n   "..., 548, MSG_DONTWAIT, NULL, 0) = 548
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24457, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, ",\2\0\0\3INSERT INTO menu_router\n   "..., 560, MSG_DONTWAIT, NULL, 0) = 560
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24446, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "\30\2\0\0\3INSERT INTO menu_router\n   "..., 540, MSG_DONTWAIT, NULL, 0) = 540
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24435, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "6\2\0\0\3INSERT INTO menu_router\n   "..., 570, MSG_DONTWAIT, NULL, 0) = 570
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24424, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "\253\2\0\0\3INSERT INTO menu_router\n   "..., 687, MSG_DONTWAIT, NULL, 0) = 687
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24413, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "\206\6\0\0\3INSERT INTO menu_router\n   "..., 1674, MSG_DONTWAIT, NULL, 0) = 1674
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24402, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "!\2\0\0\3INSERT INTO menu_router\n   "..., 549, MSG_DONTWAIT, NULL, 0) = 549
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24391, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "3\2\0\0\3INSERT INTO menu_router\n   "..., 567, MSG_DONTWAIT, NULL, 0) = 567
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24380, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "$\2\0\0\3INSERT INTO menu_router\n   "..., 552, MSG_DONTWAIT, NULL, 0) = 552
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24369, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "*\2\0\0\3INSERT INTO menu_router\n   "..., 558, MSG_DONTWAIT, NULL, 0) = 558
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24358, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "9\2\0\0\3INSERT INTO menu_router\n   "..., 573, MSG_DONTWAIT, NULL, 0) = 573
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24347, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "*\2\0\0\3INSERT INTO menu_router\n   "..., 558, MSG_DONTWAIT, NULL, 0) = 558
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24336, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "-\2\0\0\3INSERT INTO menu_router\n   "..., 561, MSG_DONTWAIT, NULL, 0) = 561
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24325, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "\33\2\0\0\3INSERT INTO menu_router\n   "..., 543, MSG_DONTWAIT, NULL, 0) = 543
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928) = 1 ([{fd=5, revents=POLLIN}])
[pid 27381] recvfrom(5, "\7\0\0\1\0\1\0\2\0\0\0", 24314, MSG_DONTWAIT, NULL, NULL) = 11
[pid 27381] sendto(5, "\6\2\0\0\3INSERT INTO menu_router\n   "..., 522, MSG_DONTWAIT, NULL, 0) = 522
[pid 27381] poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 1471228928 <unfinished ...>

所有超时都是合理的,所以我不认为这是问题所在。由于服务器配置与我的其他网站相同,我认为这是一个代码问题,但我不确定PHP中的内容会导致这种情况。

Drupal 6.28和PHP 5.5.20。

1 个答案:

答案 0 :(得分:4)

您的recvfrom/sendto只是MySQL查询,所以它没有任何问题。

插入menu_router表表明Drupal正在重建此表(请参阅:menu_rebuild() API);

  

此功能将清除并填充{menu_router}表,添加条目   到{menu_links}获取新的路由器项目,然后从中删除过时的项目   {menu_links}。

这可以由menu_rebuild_needed变量(如果设置)或外部模块(例如Devel)触发,或者只是在您已启用的主题设置中触发<&#39; < em>在每个页面上重建主题注册表。&#39;选项。

通常,重建菜单是清除缓存的一次性过程。如果以上建议无法提供帮助,您需要通过放置断点并打印回溯来检查哪个模块/代码正好调用menu_rebuild()(在includes/menu.inc中)。

一种做法(如果存在Devel)正在使用dd(),例如

function menu_rebuild() {
  dd(debug_backtrace()); // Adding temporary debug line.

然后检查您的/tmp/drupal_debug.txt文件以了解回溯详情。