DolphinScheduler项目管理页面加载缓慢?这样优化

有时候,ApacheDolphinScheduler项目管理页面会发生加载不出来的问题,浏览器查看为[httpip12345dolphinschedulerprojectspageSize=10amppageNo=1ampsearchVal=]请求超时。

17369224808319d99d1b43be0ce1ed6316c5da508d851

转载自可口可乐不甜

问题现象

有时候,Apache DolphinScheduler项目管理页面会发生加载不出来的问题,浏览器查看为[http://ip:12345/dolphinscheduler/projects?pageSize=10&pageNo=1&searchVal=]请求超时。

17369229235571460c6ab713d5a6554119525b9044b85

解决思路

  1. 查看海豚运行日志(未发现异常)

tail /home/dolphinscheduler/api-server/logs/dolphinscheduler-api.log


1736922923549a2748814c9e726387aa8ce55a60c4a21

  1. 尝试重启海豚的api-server模块

sh /home/dolphinscheduler/bin/dolphinscheduler-daemon.sh stop api-serversh /home/dolphinscheduler/bin/dolphinscheduler-daemon.sh start api-server

结果:还是加载不出来

  1. 尝试请求超时连接发现请求能出数据,但是要十多秒

    1736922923556419de59bc6614e4f6c1ab154f7a12236

  2. 尝试查看源码,可能是慢查询
    代码位置

    1736922923582798980186eadc3d6ec7aa6d355c9a07f

  3. 使用arthas查看运行情况


查看运行状况,查看是哪里运行时间长。可以看到是queryProjectListPaging方法。

trace org.apache.dolphinscheduler.api.service.impl.ProjectServiceImpl queryProjectListPaging -n 1


173692292360758375823fb66e2a3b184f8a297da02b7

进入queryProjectListPaging方法

17369229236063153af9970fa4a83bff20c59dbc70a20

尝试运行sql,发现没有很慢。

1736923118575bc100305ca7f8d8f8945b6201a0d3ad0

1736922924493bfdb83654efdbccc4400d21917c268c8

尝试运行海运再运行中的sql,这里使用了arthas加上https://ctbots.com/#/arthas/parseMybatisSql辅助获取运行的sql。

17369229244908ef31193399544b53a0fbae47588232c1736922924537aaa281a409aa5014af1cbbfd63e5560e


6. 获得慢sql,进行分析


173692321917497e34100fa9dfebb71dcbe0f07ba3f0e


通过explain分析sql可知是inst_running_count这里查询慢。查看t_ds_process_definition表就28万多数据,t_ds_process_definition_log表有1千数据。
由此可知是日志数据太多了。尝试优化这个查询,给t_ds_process_instance加索引

```

create index qwl_diy_index

    on t_ds_process_instance (process_definition_code, process_definition_version, state);

```

添加后验证,确实是快了。页面也恢复正常了。

17369229245330de47383eb24ead7b9448a404e82ae82

原文链接:https://blog.csdn.net/weixin_41673092/article/details/144510764