opendevops-cn / opendevops

CODO是一款为用户提供企业多混合云、全球一站式DevOps、自动化运维、完全开源的云管理平台、自动化运维平台
http://www.opendevops.cn/
GNU General Public License v3.0
3.77k stars 1.02k forks source link

不定时出现的请求慢问题 #28

Open pengkobe opened 4 years ago

pengkobe commented 4 years ago

按照分布式安装教程安装好之后,有些列表会经常出现加载慢,比如订单列表仓库列表,具体可以参见如下图所示。比如/v2/task/list/ 快的时候几十毫秒就 ok 了,慢的时候会超过 5 s,而且这个时间比较固定。

[root@localhost supervisor]# tail -n 20 task_scheduler.log 
[I 190919 10:17:15 web_logs:67] web server start sucessfuled.
[I 190919 10:17:22 web:2106] 200 GET /v2/task/list/ (127.0.0.1) 67.35ms
[I 190919 10:17:27 web:2106] 200 GET /v2/task/check/?list_id=28 (127.0.0.1) 5040.25ms
[I 190919 10:31:25 web:2106] 200 GET /v2/task/list/ (127.0.0.1) 92.38ms
[I 190919 10:31:31 web:2106] 200 GET /v2/task/check/?list_id=28 (127.0.0.1) 5047.83ms
[I 190919 10:31:33 web:2106] 200 GET /v2/task/check_history/?page=1&limit=18&search_val= (127.0.0.1) 5062.15ms
[I 190919 10:31:33 web:2106] 200 GET /v2/task/list/ (127.0.0.1) 5034.16ms
[I 190919 10:31:39 web:2106] 200 GET /v2/task/check/?list_id=28 (127.0.0.1) 5084.30ms
[I 190919 10:43:00 web:2106] 200 GET /v2/task/check_history/?page=1&limit=18&search_val= (127.0.0.1) 22.24ms
[I 190919 10:43:20 web:2106] 200 GET /v2/task/list/ (127.0.0.1) 20.22ms
[I 190919 10:43:25 web:2106] 200 GET /v2/task/check/?list_id=28 (127.0.0.1) 5048.11ms
[I 190919 10:50:56 web:2106] 200 GET /v2/task/list/ (127.0.0.1) 19.15ms
[I 190919 10:51:01 web:2106] 200 GET /v2/task/check/?list_id=28 (127.0.0.1) 5036.27ms
[I 190919 10:51:02 web:2106] 200 GET /v2/task/check_history/?page=1&limit=18&search_val= (127.0.0.1) 5049.55ms
[I 190919 10:51:04 web:2106] 200 GET /v2/task/list/ (127.0.0.1) 58.51ms
[I 190919 10:51:09 web:2106] 200 GET /v2/task/check/?list_id=28 (127.0.0.1) 5036.56ms
[I 190919 10:51:10 web:2106] 200 GET /v2/task/check_history/?page=1&limit=18&search_val= (127.0.0.1) 5052.04ms
[I 190919 10:51:19 web:2106] 200 GET /v2/task/list/ (127.0.0.1) 5034.76ms
[I 190919 10:51:19 web:2106] 200 GET /v2/task/check/?list_id=28 (127.0.0.1) 43.66ms
[I 190919 10:51:52 web:2106] 200 GET /v2/task_layout/temp/ (127.0.0.1) 5025.44ms

初步排查应该是 ORM 框架出现的查询问题,但是具体问题排查了老久,都没有找到答案。希望各位大神能够指导下,不胜感激!!!

task_info = session.query(TaskList).filter(TaskList.schedule != 'OK').order_by(
                -TaskList.start_time, -TaskList.list_id).offset(limit_start).limit(int(limit))

附上我的系统信息

Linux localhost.centos2 3.10.0-957.27.2.el7.x86_64 #1 SMP Mon Jul 29 17:46:05 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux