![redmine 写入性能较差(更新不是真正的多线程)](https://linux22.com/image/677741/redmine%20%E5%86%99%E5%85%A5%E6%80%A7%E8%83%BD%E8%BE%83%E5%B7%AE%EF%BC%88%E6%9B%B4%E6%96%B0%E4%B8%8D%E6%98%AF%E7%9C%9F%E6%AD%A3%E7%9A%84%E5%A4%9A%E7%BA%BF%E7%A8%8B%EF%BC%89.png)
(已经自我回答) 我正在努力解决大约 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
在处理大量 SQL 查询之后,关键时刻production.log
是提交阶段。请注意,提交是在几毫秒内完成的,但在提交之间发生了一些神秘的事情,不仅将它们序列化,而且还需要秒进入完成状态。此日志摘录完整无损 - 我没有删除中间的任何行。
(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 使用率(最大 70%,可能为 400%)。
答案1
好的,这是 SMTP 序列化事物;默认情况下它以某种方式未记录。
我已经改变了/var/www/html/redmine/config/configuration.yml
:
email_delivery:
# delivery_method: :smtp # slows down everything!
delivery_method: :async_smtp