Spying on Apache and PHP with Strace
Why Server Fault recommends it
Server Fault answerers point people to it as a hands-on walkthrough for tracing a slow Apache or PHP worker with strace when diagnosing long response times and timeouts.
Recommended by 2 people across 3 different months, 2011 to 2012.
What it is
A 15-minute screencast by spudlyo showing how to use strace to find out why an Apache worker serves a PHP page slowly. It walks through connecting with telnet, finding the worker's PID with lsof and netstat, tracing it with strace, and sorting the output to spot the slow system calls.
What people said
Strong rec thinice · 2011-12 · Server Fault · on “Long waiting times before Apache 2.2 server response (Gentoo LAMP)”
Here's an excellent primer/walktthrough [this video] for troubleshooting these kinds of issues using strace. Maximum possible memory usage: 219.7M (93% of installed RAM) This must be a low-end VPS box? You might want to dial down your MySQL settings Tune Apache to reduce the number of httpd forks Check if you can enable swapping Is APC set to automatically cache opcodes? Check using the 'apc.php' script distributed with apc.
Recommends Hrvoje Špoljar · 2011-09 · Server Fault · on “How to diagnostic a timeout PHP app?”
You can strace the process and find where the bottleneck is. Here [this video] is good video that will show you how to track the problem.
Recommends thinice · 2011-12 · Server Fault · on “Monitoring PHP process on CentOS 5.5”
Look into strace - there's a lot of good documentation and even [this video] surrounding troubleshooting this behavior.
Recommends thinice · 2012-01 · Server Fault · on “NGINX on OSX - Performing terribly slow”
Start by stripping out all unnecessary configuration options. Get the setup to a bare-bones 'Im only serving HTML files' default configuration. Remove optimizations. Slowly start adding aspects back in a few at a time, restart your stack and test. If you're feeling ambitious, you can run strace on a single server process to get timings. Have a look at this for a crash course [this video] .
Cites thinice · 2012-05 · Server Fault · on “PHP using lots of memory/time outside of script?”
Chances are you've got an inefficient module enabled in Drupal. Start by disabling all of those and seeing if that changes anything. Additionally, it sounds like your trace isn't a real trace, have a look at this to get a better trace: [this video] An Opcode cache (APC) will only get you so far in the name of performance, so I'd look there last to improve performance.
Cites ThomasReggi · 2012-08 · Server Fault · on “HTTPS is over 50 times slower then HTTP”
@cjc Great trick, I'm using a combination of `telnet`, `lsof`, `netstat` and `strace` but `telnet` keeps closing the output from `strace` is `23724 0.847033 accept(6, {sa_family=AF_INET6, sin6_port=htons(53668), inet_pton(AF_INET6, "::ffff:71.61.77.135", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, [28]) = 16`. I learned how to get the process id for the worker from here [this video] .