Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文章多的时候占用资源很大 #1583

Closed
catsalty opened this issue Dec 9, 2021 · 14 comments
Closed

文章多的时候占用资源很大 #1583

catsalty opened this issue Dec 9, 2021 · 14 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@catsalty
Copy link

catsalty commented Dec 9, 2021

是什么版本出现了此问题?

1.4.15

使用的什么数据库?

H2

使用的哪种方式部署?

Docker

在线站点地址

发生了什么?

文章数1.5k+ , 首页刷新,cpu瞬间打到80%。
独立服务器,配置如下:

CPU model            : Intel(R) Core(TM) i3-2130 CPU @ 3.40GHz
Number of cores      : 4
CPU frequency        : 3281.531 MHz
Total size of Disk   : 1843.2 GB (1.2 GB Used)
Total amount of Mem  : 7722 MB (103 MB Used)

top:

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                                            
 965495 root      20   0 4357612   1.0g  21788 S  81.4  12.8  57:08.51 java                                                                                               
   1206 root      20   0 3645320 113132  23092 S   0.3   1.4  42:04.49 dockerd                                                                                            
1068623 root      20   0       0      0      0 I   0.3   0.0   0:00.19 kworker/u8:0-ext4-rsv-conversion                                                                   
1069759 debian    20   0    8980   3708   3068 R   0.3   0.0   0:01.22 top                                                                                                
      1 root      20   0  164320   6756   4632 S   0.0   0.1   0:22.72 systemd                                                                                            
      2 root      20   0       0      0      0 S   0.0   0.0   0:00.05 kthreadd                                                                                           
      3 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_gp           

相关日志输出

No response

附加信息

另一个bug:
文章数超1k之后,模板渲染返回问post.id 值中间会多一个逗号:
如:期望 1234
返回:1,234

@catsalty catsalty added the kind/bug Categorizes issue or PR as related to a bug. label Dec 9, 2021
@JohnNiang
Copy link
Member

请提供一下系统的 load average 数值,单纯看 CPU 峰值看不出什么。

@ruibaby
Copy link
Member

ruibaby commented Dec 9, 2021

文章数超1k之后,模板渲染返回问post.id 值中间会多一个逗号

这个问题建议向对应主题提交 issue。

@catsalty
Copy link
Author

catsalty commented Dec 9, 2021

请提供一下系统的 load average 数值,单纯看 CPU 峰值看不出什么。


top - 06:48:51 up 3 days, 23:42,  1 user,  load average: 0.24, 0.42, 0.70
Tasks: 133 total,   1 running, 132 sleeping,   0 stopped,   0 zombie
%Cpu(s): 20.4 us,  0.5 sy,  0.0 ni, 79.1 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :   7856.1 total,   1051.3 free,   4201.8 used,   2603.1 buff/cache
MiB Swap:    512.0 total,    343.0 free,    169.0 used.   3364.2 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                                            
 965495 root      20   0 4357612   1.0g  21788 S  90.7  12.9  59:31.55 java                                                                                               
   1206 root      20   0 3645320 113132  23092 S   0.7   1.4  42:06.83 dockerd                                                                                            
 918595 root      20   0   10.9g  60388  22728 S   0.3   0.8   6:11.80 node                                                                                               
1059315 message+  20   0   34084  10264   4584 S   0.3   0.1   0:06.90 nginx                                                                                              
      1 root      20   0  164320   6756   4632 S   0.0   0.1   0:22.72 systemd                                                                                            
      2 root      20   0       0      0      0 S   0.0   0.0   0:00.05 kthreadd                                                                                           
      3 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_gp                                                                                             
      4 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_par_gp            

@catsalty
Copy link
Author

catsalty commented Dec 9, 2021

请提供一下系统的 load average 数值,单纯看 CPU 峰值看不出什么。


top - 06:48:51 up 3 days, 23:42,  1 user,  load average: 0.24, 0.42, 0.70
Tasks: 133 total,   1 running, 132 sleeping,   0 stopped,   0 zombie
%Cpu(s): 20.4 us,  0.5 sy,  0.0 ni, 79.1 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :   7856.1 total,   1051.3 free,   4201.8 used,   2603.1 buff/cache
MiB Swap:    512.0 total,    343.0 free,    169.0 used.   3364.2 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                                            
 965495 root      20   0 4357612   1.0g  21788 S  90.7  12.9  59:31.55 java                                                                                               
   1206 root      20   0 3645320 113132  23092 S   0.7   1.4  42:06.83 dockerd                                                                                            
 918595 root      20   0   10.9g  60388  22728 S   0.3   0.8   6:11.80 node                                                                                               
1059315 message+  20   0   34084  10264   4584 S   0.3   0.1   0:06.90 nginx                                                                                              
      1 root      20   0  164320   6756   4632 S   0.0   0.1   0:22.72 systemd                                                                                            
      2 root      20   0       0      0      0 S   0.0   0.0   0:00.05 kthreadd                                                                                           
      3 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_gp                                                                                             
      4 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_par_gp            

17ce.com 测速几次直接挂。提示数据库申请不到jdbc池,..之前同配置的站wp会好很多。

@catsalty
Copy link
Author

catsalty commented Dec 9, 2021

附上log:
_logs.txt

@ruibaby
Copy link
Member

ruibaby commented Dec 9, 2021

@ByeCode 我们后续会尝试根据你的配置和文章数据进行尝试复现这个问题。

@ruibaby
Copy link
Member

ruibaby commented Dec 9, 2021

另外建议配置一下启动参数(Xms Xmx),将其调高再观察观察。

https://github.com/halo-dev/halo-common/blob/06edede548ef1c4765bd178cdbef072128c1e10f/halo.service#L10

@catsalty
Copy link
Author

catsalty commented Dec 9, 2021

另外建议配置一下启动参数(Xms Xmx),将其调高再观察观察。

https://github.com/halo-dev/halo-common/blob/06edede548ef1c4765bd178cdbef072128c1e10f/halo.service#L10

试了一下

-Xmx1024m -Xms1024m

并没有太大帮助,

@catsalty
Copy link
Author

catsalty commented Dec 9, 2021

另外建议配置一下启动参数(Xms Xmx),将其调高再观察观察。
https://github.com/halo-dev/halo-common/blob/06edede548ef1c4765bd178cdbef072128c1e10f/halo.service#L10

试了一下

-Xmx1024m -Xms1024m

并没有太大帮助,

太要命了,配置完重启docker之后数据还回滚了!

@guqing
Copy link
Member

guqing commented Dec 9, 2021

@ByeCode 没有映射卷到宿主机吗, 我们会尽快尝试复现

@catsalty
Copy link
Author

catsalty commented Dec 9, 2021

@ByeCode 没有映射卷到宿主机吗, 我们会尽快尝试复现

映射了..要不怎么能是“回滚”呢

@ruibaby
Copy link
Member

ruibaby commented Dec 9, 2021

@ByeCode 初步判断很可能是 h2 database 带来的问题。如果可以的话,你可以尝试在后台导出数据之后切换到 MySQL 试试。

https://docs.halo.run/user-guide/backup-migration#数据备份

@ruibaby
Copy link
Member

ruibaby commented Dec 12, 2021

@ByeCode 经过我们的多次测试,在 2000 左右的文章,每篇 8000 字符的情况下,确实会出现加载慢的情况,但是没有复现出数据库链接失败的情况。且使用 MySQL 的话,情况会好很多。我们建议你这个数据量暂时可以考虑使用 MySQL。我们已经提交了两个 issue 来追踪解决性能问题

#1586
#1587

感谢 @guqing 的测试。

@ruibaby ruibaby added kind/feature Categorizes issue or PR as related to a new feature. and removed kind/bug Categorizes issue or PR as related to a bug. labels Dec 12, 2021
@catsalty
Copy link
Author

@ByeCode 经过我们的多次测试,在 2000 左右的文章,每篇 8000 字符的情况下,确实会出现加载慢的情况,但是没有复现出数据库链接失败的情况。且使用 MySQL 的话,情况会好很多。我们建议你这个数据量暂时可以考虑使用 MySQL。我们已经提交了两个 issue 来追踪解决性能问题

#1586 #1587

感谢 @guqing 的测试。

tks for fixing this issue

@ruibaby ruibaby closed this as completed May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

4 participants