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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you are on a linux server, a heavy solution could be to strace your Apache processes.
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).
You invoke it like that:
strace -f -p pid
pid being the pid of the process you want to trace.
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.
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 !