(已经自我回答)我正在与大约 100 个用户的 redmine 性能不佳作斗争。为了测试它,我设置了一个简单的场景来更新五个不同示例问题的“完成百分比”。所有更新都在同一秒开始,使用curl
. 令我惊讶的是,redmine 中的更新似乎是序列化的(我的意思是不是多线程的),时序如下:
real 0m1.122s
real 0m1.404s
real 0m2.258s
real 0m2.782s
real 0m3.151s
real 0m3.336s
或者另一种尝试,当其他会话的一些处理也受到阻碍时:
real 0m7.492s
real 0m7.803s
real 0m8.045s
real 0m8.246s
real 0m8.597s
real 0m8.825s
production.log
在处理大量 SQL 查询后的关键时刻是 COMMIT 阶段。请注意 COMMIT 是如何在毫秒内完成的,但在 COMMIT 之间发生了一些神秘的事情,不仅将它们序列化,而且需要几秒钟才能达到 Completed 状态。此日志摘录完好无损 - 我没有删除中间的任何行。
(0.6ms) SELECT COUNT(*) FROM `custom_workflows` WHERE `custom_workflows`.`active` = 1 AND `custom_workflows`.`observable` = 'issue' AND (is_for_all OR EXISTS (SELECT * FROM custom_workflows_projects WHERE project_id=123 AND custom_workflow_id=id))
(30.1ms) COMMIT
Redirected to http://redmine.mydomain.local/issues/11973
Completed 302 Found in 7418.4ms (ActiveRecord: 135.8ms)
(0.6ms) SELECT COUNT(*) FROM `custom_workflows` WHERE `custom_workflows`.`active` = 1 AND `custom_workflows`.`observable` = 'issue' AND (is_for_all OR EXISTS (SELECT * FROM custom_workflows_projects WHERE project_id=123 AND custom_workflow_id=id))
(24.8ms) COMMIT
Redirected to http://redmine.mydomain.local/issues/9240
Completed 302 Found in 7738.3ms (ActiveRecord: 57.4ms)
(0.4ms) SELECT COUNT(*) FROM `custom_workflows` WHERE `custom_workflows`.`active` = 1 AND `custom_workflows`.`observable` = 'issue' AND (is_for_all OR EXISTS (SELECT * FROM custom_workflows_projects WHERE project_id=123 AND custom_workflow_id=id))
(25.9ms) COMMIT
Redirected to http://redmine.mydomain.local/issues/9614
Completed 302 Found in 7949.0ms (ActiveRecord: 135.7ms)
(0.5ms) SELECT COUNT(*) FROM `custom_workflows` WHERE `custom_workflows`.`active` = 1 AND `custom_workflows`.`observable` = 'issue' AND (is_for_all OR EXISTS (SELECT * FROM custom_workflows_projects WHERE project_id=123 AND custom_workflow_id=id))
(24.6ms) COMMIT
Redirected to http://redmine.mydomain.local/issues/12016
Completed 302 Found in 8058.5ms (ActiveRecord: 102.5ms)
(0.5ms) SELECT COUNT(*) FROM `custom_workflows` WHERE `custom_workflows`.`active` = 1 AND `custom_workflows`.`observable` = 'issue' AND (is_for_all OR EXISTS (SELECT * FROM custom_workflows_projects WHERE project_id=123 AND custom_workflow_id=id))
(21.2ms) COMMIT
Redirected to http://redmine.mydomain.local/issues/8853
Completed 302 Found in 8472.5ms (ActiveRecord: 90.4ms)
(0.5ms) SELECT COUNT(*) FROM `custom_workflows` WHERE `custom_workflows`.`active` = 1 AND `custom_workflows`.`observable` = 'issue' AND (is_for_all OR EXISTS (SELECT * FROM custom_workflows_projects WHERE project_id=123 AND custom_workflow_id=id))
(27.9ms) COMMIT
Redirected to http://redmine.mydomain.local/issues/10007
Completed 302 Found in 8700.4ms (ActiveRecord: 137.4ms)
我已经检查过的内容:
- 乘客状态的线程数绰绰有余
- apache2 httpd 的进程数绰绰有余
- mysql 5.1 使用 innodb
- innotop 不显示锁
- innotop 不会过多的 I/O
- iostat 没有显示过多的 I/O(大约 10-15 IOPS,磁盘最大 17% 的时间使用)
- top 没有显示过多的 CPU 使用率(最多可能 400% 的 70%)。