How to make Drupal hog CPU cycles
Jan. 29th, 2006 11:24 pmWell, I had a fun weekend. It all started on Friday:
Web Host: Dude, your Drupal installation is taking up too much CPU time.
Me: How much?
WH: It's spinning the CPU for 60-90 seconds on a single page load.
Me: Oops.
WH: Here are the times and URLs it's happened.
Me: Hmm... those correspond to my crontabs...
So, after some more investigation, and placing of debugging hooks into poormanscron, I determined that the search module's search_cron() is chewing up lots of CPU time and even timing out in some cases.
So, I told the search module to only index 10 pages per run instead of 100. That lowered the load, but it's still taking up to a minute in some runs. I did some more experimenting and discovered that sometimes the module makes thousands of iterations, presumably to index a bunch of words from a really big document. This means that my next step is to take some of the really large documents on my website and break them down into smaller sections to make for shorter cron runs.
The other thing I have yet to resolve is why, when the admin page says that 100% of the nodes are indexed, the counter goes back to 0% on the next cron run and everything gets indexed again. Since I have 3 other Drupal powered sites that don't do this, I'm guessing that something go corrupted on mine. Whee fun. :-)
I'd also like to give mad props to my webhosting provider, Nearly Free Speech, for working with me on the problem. I was able to have some seriously geeky discussions with them while trying to figure out the cause of the problem. They totally rock when it comes to tech support.
And that's pretty much how my weekend went.
Web Host: Dude, your Drupal installation is taking up too much CPU time.
Me: How much?
WH: It's spinning the CPU for 60-90 seconds on a single page load.
Me: Oops.
WH: Here are the times and URLs it's happened.
Me: Hmm... those correspond to my crontabs...
So, after some more investigation, and placing of debugging hooks into poormanscron, I determined that the search module's search_cron() is chewing up lots of CPU time and even timing out in some cases.
So, I told the search module to only index 10 pages per run instead of 100. That lowered the load, but it's still taking up to a minute in some runs. I did some more experimenting and discovered that sometimes the module makes thousands of iterations, presumably to index a bunch of words from a really big document. This means that my next step is to take some of the really large documents on my website and break them down into smaller sections to make for shorter cron runs.
The other thing I have yet to resolve is why, when the admin page says that 100% of the nodes are indexed, the counter goes back to 0% on the next cron run and everything gets indexed again. Since I have 3 other Drupal powered sites that don't do this, I'm guessing that something go corrupted on mine. Whee fun. :-)
I'd also like to give mad props to my webhosting provider, Nearly Free Speech, for working with me on the problem. I was able to have some seriously geeky discussions with them while trying to figure out the cause of the problem. They totally rock when it comes to tech support.
And that's pretty much how my weekend went.