What other strategies are there for seeing CPU bottlenecks in a large PHP application?
December 5, 2011 1:56 PM Subscribe
How can I track down the cause of periodic spikes in CPU usage caused by a plugin-bloated WordPress install on a LAMP server?
posted by cowbellemoo to computers & internet (5 answers total)
Just a few notes about the setup: about 18k pieces of content, 80k users, 30ish plugins, with the apache and mysql servers running on a Large (7gb ram) AWS instance. I have WordPress-level caching implemented which uses XCache PHP opcode cache. I've set fairly conservative limits on the Apache worker process settings (each process takes up a bunch of memory). I've also run some tuning scripts on the MySQL server and made sure that a 'long query' wasn't the culprit. I've even run a Xdebug profile of a typical page load and couldn't see any obvious bottlenecks. Everything is pretty stable for the most part while I work on reimplementing features that will let me get rid of some of the plugin bloat.
However, once or twice a day, the CPU usage goes nuts for five minutes and causes load spikes of 40-50. Top doesn't show me much except that apache/mysql are getting hammered. Traffic patterns don't seem to effect when it will happen, either, and it happens too irregularly for me to think it's a scheduled task. Apache's error logs don't turn up anything obvious either. I can't recreate the spikes on an identical development server (with zero traffic).
How can I find what URL requests or scripts are directly related to the CPU spike? Is there some way to correlate processor resource consumption with access logs? What other strategies are there for seeing CPU bottlenecks in a large PHP application?