You are here:  » Hosting provider warns me about server CPU overload due script

Support Forum



Hosting provider warns me about server CPU overload due script

Submitted by Al on Fri, 2009-07-03 09:44 in

My hosting provider has canceled all Cron jobs due to: shared hosting server heavy overload. CPU was used for 100%

I am running three scripts, once a day with a few hours interval.
The importall.php

<?php
  header("Content-Type: text/plain");
  passthru("php ../scripts/import.php @MODIFIED");
?>

And another one which downloads the feeds first and the imports them automatically. I must say there are some large feeds.
What can I do about this?

Submitted by support on Fri, 2009-07-03 11:09

Hello Al,

The first tip for reducing load during import, if at all possible depending on your setup, is to use import.php @ALL instead of @MODIFIED. This is because deleting thousands of rows from an already very large is a very slow process.

However, I appreciate that it might not be desirable to have your site down for as long as it takes to perform the import, so there is a very nice modification described in the following thread that imports to a temporary table, and once completed switches it over to the live table. This will mean that you can then use @ALL without interruption to your site:

http://www.pricetapestry.com/node/3355

In addition, several users have found that inserting a 1 second sleep() every 100 products or so during the import also make a significant difference...

http://www.pricetapestry.com/node/1216

If you're not sure about any of the above modifications, email me the files across and I'll patch them for you...

Cheers,
David.

Submitted by bat on Mon, 2011-06-20 18:30

I do not do CRON jobs but I submit the script link in my browser, ending in @MODIFIED

So, is the best way to avoid overusage of CPU by using the same script link but @ALL? Or would using the Slow Import work better instead?

Submitted by support on Tue, 2011-06-21 07:30

Hello Bat,

@ALL will always be much lower processor load as there is no need to DELETE per feed (the products table is emptied using TRUNCATE at the start) but this only applies to the regular import script. It is not by default enabled in slow import as that only works for CSV feeds so if you have XML feeds registered also they would not be imported.

However, if you do ONLY have CSV feeds on your site, then it is easy to modify admin/feeds_import_slow.php to TRUNCATE the products table when using @ALL. To do this, first look for the following code at line 394:

print "<p><a href='feeds_import_slow.php?filename=@ALL&startTime=".$now."'>mport All</a></p>";

...and REPLACE with:

print "<p><a href='feeds_import_slow.php?filename=@ALL&truncate=1&startTime=".$now."'>mport All</a></p>";

Finally, look for the following code beginning at line 165:

    if ($_GET["filename"]=="@ALL")
    {

...and REPLACE with;

    if ($_GET["filename"]=="@ALL")
    {
      if (isset($_GET["truncate"]))
      {
        $sql = "TRUNCATE `".$config_databaseTablePrefix."products`";
        database_queryModify($sql,$result);
      }

Hope this helps!

Cheers,
David.
--
PriceTapestry.com