如何找出是什么使我的PHP应用程序挂起Apache服务器? [英] How to find out what makes my PHP application to hang the Apache server?

查看:179
本文介绍了如何找出是什么使我的PHP应用程序挂起Apache服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,我的PHP应用程序有时会挂起和Apache服务器需要很长的重启。有没有一些方法来确定什么可能导致此挂断?

I am running into an issue where my PHP application hangs sometimes and the Apache server takes long to restart. Is there some way to determine what might cause this hang up?

推荐答案

如果你是在Linux服务器上,一个沉重的解决方案是与strace你的Apache进程。

If you are on a linux server, a heavy solution could be to strace your Apache processes.

这将为您提供一个由Apache进程所做的所有系统调用(和参数),并最终找到什么可以挂(或找出你的脚本试图获取资源 - 例如一个文件 - 它能够 T上读,打开一个套接字,等待超时,等等)。

It will provide you with all the system calls (and parameters) done by the Apache processes, and eventually find what could be hanging (or find out that your script tries to get a resource - eg a file - that it can't read, open a socket and wait until the timeout, etc).

您调用它这样的:

使用strace -f -p PID

strace -f -p pid

PID是要跟踪的进程的PID。

pid being the pid of the process you want to trace.

在你的情况,我建议改变你的Apache服务器的配置(如果需要)有服务器的数量少催生。您获取它们的PID与常规的ps命令。
然后,你可以在同一时间与strace数的PID,加入-p PID1 -p PID2等。
您还可以使用-o文件名和-ff有写入filename.pid文件的每个过程strace的。然后你运行你的HTTP请求。已处理您的请求的进程将是最大的.pid文件。

In your case, I recommend changing the configuration of your Apache server (if necessary) to have a little number of servers spawned. You fetch their pids with a regular ps command. Then you can strace several pids at the same time, by adding -p pid1 -p pid2 etc. You can also use -o filename and -ff to have each process strace written to filename.pid files. Then you run your HTTP request. The process that has processed your request will be in the biggest .pid file.

也可以使用-s大小指定文本的长度来捕捉,例如在写系统调用,否则你可能会错过有趣的信息。

Also use -s size to specify the length of text to capture, for example in 'write' syscalls, or else you might miss interesting information.

它可以是很难读懂,但可以提供真正有用的信息。我经常使用它了绝望的处境!

It can be hard to read, but can provide really helpful information. I use it frequently for desperate situations !

这篇关于如何找出是什么使我的PHP应用程序挂起Apache服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆