Php5-CGI 一次使用 CPU 就达到 100%。我该如何找出罪魁祸首?

Php5-CGI 一次使用 CPU 就达到 100%。我该如何找出罪魁祸首?

我在 Magento 商店遇到了一个奇怪的问题。当我们遇到流量高峰时,服务器崩溃了,所以我检查了发生了什么。使用 htop 我发现 PHP5 CGI 在一次点击中占用了高达 100% 的 CPU。我使用的是 vps,但资源应该足以处理一次点击。由于我使用的是 Magento,我认为(希望)它不是写得不好的 PHP,但我真的不知道。我还使用 varnish 作为缓存,因此 Apache 在端口 8080 上运行,但这应该没什么关系。

操作系统是 Ubuntu 12.04.5 LTS

我的问题:我如何才能查明导致这种情况的原因?有什么好的、系统的方法来找出罪魁祸首?

这是我的 Apache 错误日志中的最后几条记录。我没有发现任何异常。

[Tue Apr 28 16:38:54 2015] [warn] RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
[Tue Apr 28 16:38:54 2015] [warn] RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
[Tue Apr 28 16:38:54 2015] [warn] RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
[Tue Apr 28 16:38:54 2015] [warn] RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
[Tue Apr 28 16:38:54 2015] [warn] RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
[Tue Apr 28 16:38:54 2015] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Tue Apr 28 16:38:54 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/lib/apache2/suexec)
[Tue Apr 28 16:38:54 2015] [notice] Digest: generating secret for digest authentication ...
[Tue Apr 28 16:38:54 2015] [notice] Digest: done
[Tue Apr 28 16:38:54 2015] [error] python_init: Python version mismatch, expected '2.7.2+', found '2.7.3'.
[Tue Apr 28 16:38:54 2015] [error] python_init: Python executable found '/usr/bin/python'.
[Tue Apr 28 16:38:54 2015] [error] python_init: Python path being used '/usr/lib/python2.7/:/usr/lib/python2.7/plat-linux2:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload'.
[Tue Apr 28 16:38:54 2015] [notice] mod_python: Creating 8 session mutexes based on 40 max processes and 0 max threads.
[Tue Apr 28 16:38:54 2015] [notice] mod_python: using mutex_directory /tmp
[Tue Apr 28 16:38:54 2015] [warn] RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
[Tue Apr 28 16:38:54 2015] [warn] RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
[Tue Apr 28 16:38:54 2015] [warn] RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
[Tue Apr 28 16:38:54 2015] [warn] RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
[Tue Apr 28 16:38:54 2015] [warn] RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
[Tue Apr 28 16:38:54 2015] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Tue Apr 28 16:38:54 2015] [notice] Apache/2.2.22 (Ubuntu) DAV/2 mod_fcgid/2.3.6 mod_python/3.3.1 Python/2.7.3 mod_ssl/2.2.22 OpenSSL/1.0.1 mod_perl/2.0.5 Perl/v5.14.2 configured -- resuming normal operations
[Tue Apr 28 16:39:07 2015] [notice] caught SIGTERM, shutting down
[Tue Apr 28 16:39:09 2015] [warn] RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
[Tue Apr 28 16:39:09 2015] [warn] RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
[Tue Apr 28 16:39:09 2015] [warn] RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
[Tue Apr 28 16:39:09 2015] [warn] RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
[Tue Apr 28 16:39:09 2015] [warn] RSA server certificate CommonName (CN) `Parallels Panel' does NOT match server name!?
[Tue Apr 28 16:39:09 2015] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Tue Apr 28 16:39:09 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/lib/apache2/suexec)
[Tue Apr 28 16:39:09 2015] [notice] Digest: generating secret for digest authentication ...
[Tue Apr 28 16:39:09 2015] [notice] Digest: done

这是 $ top 的结果

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 6452 someuser   20   0  323m  78m 9136 R   85  0.5   0:08.91 php5-cgi
 6456 someuser   20   0  296m  52m 9144 R   65  0.3   0:07.14 php5-cgi
 6454 someuser   20   0  294m  50m 9232 S   62  0.3   0:07.43 php5-cgi
 6448 someuser   20   0     0    0    0 Z   49  0.0   0:13.56 php5-cgi <defunct>
 6446 someuser   20   0     0    0    0 Z   43  0.0   0:29.30 php5-cgi <defunct>

我可以为您提供更多信息,但目前我不知道从哪里开始寻找。

谢谢!

相关内容