strace apache or process to detect bottlenecks

Sometimes you have a multi threaded / multi processed application and you need to see where are things hanging.

ps auxw | grep sbin/apache | awk '{print"-p " $2}' | xargs strace

 

nJoy šŸ˜‰

Monitoring a bottleneck with strace

If let’s say Mysql is slow at performing a task you can check what is the bottleneck using strace to attach to the process.

<span style="color: #00ff00;">$ ps -ef|grep -i mysql</span>

Identify the process id then

<span style="color: #00ff00;">$ strace -cp &lt;pid&gt;</span>

Leave it 10 seconds or a minute thenĀ ^C. That will tell you where the process is spending its time, e.g. it could just be waiting for the disk if you seenĀ readĀ andĀ writeĀ dominate.

Njoy šŸ™‚