最近我的服务器遇到了一个大问题,我使用 tomcat 作为 Controller ,apache 作为网络服务器,但突然 apache 消耗了 98% 的 CPU,因此我的网站挂起,我多次杀死这个进程,但这个进程再次启动并再次消耗 CUP,有人可以为此提供一些解决方案吗?
日志:
根21937 2264 5.8 9181548 246700? SLl 08:44 3168:44 apache -c httpd.conf 根 24842 0.0 0.0 27400 3220? S 04:16 0:00 cpdavd - 接受 2077、2078、2079 和 2080 上的连接( hibernate ) 根28715 0.0 0.0 128548 3984? S 09:15 0:02/usr/sbin/httpd 根 28726 0.0 0.0 128548 3984 ? S 09:15 0:02/usr/sbin/httpd 根 29283 0.0 0.0 128548 3988 ? S 09:18 0:02/usr/sbin/httpd 根 29391 0.0 0.0 128548 3980 ? S 09:18 0:02/usr/sbin/httpd 根 29786 0.0 0.0 128548 3988 ? S 09:20 0:02/usr/sbin/httpd 根 29825 0.0 0.0 128548 3988 ? R 09:20 0:02/usr/sbin/httpd 根 29857 0.0 0.0 128548 3980 ? S 09:20 0:02/usr/sbin/httpd 根 30022 0.0 0.0 128548 3980 ? S 09:21 0:01/usr/sbin/httpd 根 32218 0.0 0.0 128548 3844 ? S 04:50 0:03/usr/sbin/httpd 根 32223 0.0 0.0 128548 3984 ? S 04:50 0:07/usr/sbin/httpd 根 32284 0.0 0.0 128548 3984 ? S 04:51 0:08/usr/sbin/httpd 根 32311 0.0 0.0 128548 3984 ? S 04:51 0:08/usr/sbin/httpd 根 32342 0.0 0.0 128548 3988 ? S 04:51 0:08/usr/sbin/httpd 根 32345 0.0 0.0 128548 3984 ? S 04:51 0:08/usr/sbin/httpd 根 32349 0.0 0.0 128548 3980 ? S 04:51 0:08/usr/sbin/httpd 根 32354 0.0 0.0 128548 3980 ? S 04:51 0:08/usr/sbin/httpd 根 32373 0.0 0.0 128548 3988 ? S 04:51 0:08/usr/sbin/httpd 根 32409 0.0 0.0 128548 3980 ? S 04:51 0:08/usr/sbin/httpd 根 32493 0.0 0.0 128548 3980 ? S 04:51 0:08/usr/sbin/httpd 根 32551 0.0 0.0 128548 3984 ? S 04:52 0:08/usr/sbin/httpd 根 32567 0.0 0.0 128548 3988 ? S 04:52 0:07/usr/sbin/httpd 根 32657 0.0 0.0 128548 3980 ? S 04:52 0:08/usr/sbin/httpd 根 32751 0.0 0.0 128548 3980 ? S 04:52 0:08/usr/sbin/httpd
最佳答案
需要调整 httpd.conf(或 apache2.conf,取决于版本)中的设置。
运行这两个命令之一将告诉您 Apache 正在使用的内存量: ps -ylC httpd | ps -ylC awk '{x += $8;y += 1} END {print "Apache 内存使用情况 (MB): "x/1024; print "平均进程大小 (MB): "x/((y-1)*1024)}'
ps -ylC apache2 | ps -ylC apache2 | ps -ylC apache2 | ps -ylC apache2 | awk '{x += $8;y += 1} END {print "Apache 内存使用情况 (MB): "x/1024; print "平均进程大小 (MB): "x/((y-1)*1024)}'
我要调整的第一件事是 prefork 设置以及 httpd.conf 中的其他 IfModule 部分
这里有一些指南,其中包含许多 Apache 调整建议:
https://www.digitalocean.com/community/tutorials/how-to-optimize-apache-web-server-performance http://www.monitis.com/blog/25-apache-performance-tuning-tips/
关于java - Apache httpd CPU 使用率高,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43053548/