1
ccrstudioweb
smartpartner and 100% cpu usage by APACHE

Hi all!
I instaled smartpartner 2.0 but I got only blank pages, so I decided to install SmartPartner version 1.4 (RC 1).

WHAT I WANT:
I tested several moduls in order to have an yellow pages site and a list of number fones of my city (about 17,000) and smartpartner was what best fit my propose (If someone has a better idea is welcome)

WHAT I USE:
XOOPS 2.0.18.1
SmartPartner version 1.4 (RC 1).
Easy PHP 2.0.0.0
phpMyAdmin 2.9.1.1
MySQL: 5.0.22
PHP Version 5.2.0

THE PROBLEM
I inserted the 17,000 phone numbers on DB.
When I do a search using XOOPS native sercher, Is everything OK, But when I enter the smartpartner category listing (eG:http://localhost/ltlnossalista/modules/smartpartner/index.php?view_category_id=3), there are a big delay and a 100% CPU usage, which ends on blank page sometimes.
The funniest is that even if i go to another page, the usage of CPU continues.
look:
Resized Image

THE CODES:
MYSQL TABLES:
CREATE TABLE `ccr091202_smartpartner_partner` (
  `
idint(11NOT NULL auto_increment,
  `
categoryidint(11NOT NULL default '11',
  `
weightint(10NOT NULL default '0',
  `
datesubint(11NOT NULL default '1259850053',
  `
hitsint(10NOT NULL default '0',
  `
hits_pageint(10NOT NULL default '0',
  `
urlvarchar(150) default '',
  `
imagevarchar(150NOT NULL default '-1',
  `
image_urlvarchar(255NOT NULL default '',
  `
titlevarchar(255NOT NULL default '',
  `
summarytext NOT NULL default 'Pirassununga/SP',
  `
descriptiontext NOT NULL default '  ',
  `
contact_namevarchar(255NOT NULL default '',
  `
contact_emailvarchar(255NOT NULL default '',
  `
contact_phonevarchar(255NOT NULL default '',
  `
adresstext NOT NULL,
  `
statustinyint(1NOT NULL default '2',
  `
email_privtinyint(1NOT NULL default '0',
  `
phone_privtinyint(1NOT NULL default '0',
  `
adress_privtinyint(1NOT NULL default '0',
  
PRIMARY KEY  (`id`),
  
KEY `status` (`status`)
ENGINE=MyISAM  DEFAULT CHARSET=utf8 COMMENT='SmartPartner by marcan' AUTO_INCREMENT=10 ;


INSERT INTO `ccr091202_smartpartner_partner` (`id`, `categoryid`, `weight`, `datesub`, `hits`, `hits_page`, `url`, `image`, `image_url`, `title`, `summary`, `description`, `contact_name`, `contact_email`, `contact_phone`, `adress`, `status`, `email_priv`, `phone_priv`, `adress_priv`) VALUES 
(10001110125985005300'''-1''''Pedro de Carvalho''Pirassununga/SP'' ''''''3561 9057''Rua João felício Filho, 710 - Jardim Redentor'2000),
(
10002110125985005300'''-1''''Márcia Montovani''Pirassununga/SP'' ''''''3561 1234''Rua Mascarenhas pedroso, 710 - Jardim Redentor'2000),
(
10003110125985005300'''-1''''Carmo castro''Pirassununga/SP'''''' ''3561 4321''Rua José Felício, 2710 - Jardim Rntor'2000); 
AND 
SO ON


THE PHP (smartpartner/index.php?view_category_id):
<?php

/**
* $Id: index.php,v 1.27 2006/02/13 17:42:12 malanciault Exp $
* Module: SmartPartner
* Author: The SmartFactory <www.smartfactory.ca>
* Licence: GNU
*/


/**
*Ceci nous produira un tableau de forme:
*
*PartnersArray[] =
*     PartnersArray[TopCat1][info] = (nom, description)
*     PartnersArray[TopCat1][partners] = array de partner (via fct get_partners_array())
*      PartnersArray[TopCat1][subcats][0][info] = (nom, description)
*      PartnersArray[TopCat1][subcats][0][partners] = array de partner
*      PartnersArray[TopCat1][subcats][0][subcats]....
*    Ainsi de suite
*
*ex: PartnersArray[TopCat1][partners][0][nom] contiendra le nom du 1er partenaire de TopCat1
*       
*/

/**
*Loop inside the array of all partners to match with current category
*
*param $categoryid - id of the current category 
*return array of partners for the current category
*/
function get_partners_array($categoryid){
    
    foreach (
$every_partners_array as $partnerObj ){
        if(
$partnerObj->categoryid() == $categoryid && ($view_category_id || (!$view_category_id && sizeof($partners) < $xoopsModuleConfig['percat_user']))){
            
$partner $partnerObj->toArray('index');
            
$partners[] = $partner;
        }
    }
    return 
$partners
}

/**
*Loop inside the array of all categories to find subcats for current category
*recusrive function: for each subcat found, call to function getcontent to
*get partners and subcats within it
*
*param $categoryid - id of the current category 
*return array of subcats for the current category
*/
function get_subcats($every_categories_array,$categoryid$level){

    
//global $every_categories_array;
    
$subcatArray = array();
    
$level++;
    
    foreach (
$every_categories_array as $subcatObj) {
             
        if(
$subcatObj->parentid() == $categoryid ){
            
$subcatArray[] = get_cat_content($every_categories_array,$subcatObj,$level);
        }
    }
    return 
$subcatArray;
}

/**
*Retrieve content for the current category
*
*param $categoryid - id of the current category 
*return array of content for the current category
*/
function get_cat_content($every_categories_array$categoryObj,$level){
    
$category = array();
    
$decalage='';
    for(
$i=0;$i<$level;$i++){
        
$decalage .= '--';
    }
    
$decalage .= ' ';
    
$category['title'] = $decalage.''.$categoryObj->name();
    
$category['description'] = $categoryObj->description();
    
$category['link_view'] = $categoryObj->getCategoryUrl();
    
$category['partners'] = get_partners_array($categoryObj->categoryid());
    
$category['image_url'] = $categoryObj->getImageUrl(true);
    
$category['subcats'] = get_subcats($every_categories_array,$categoryObj->categoryid(),$level);
    return 
$category;
}

include 
"header.php";
$xoopsOption['template_main'] = 'smartpartner_index.html';
include 
XOOPS_ROOT_PATH."/header.php";
include 
"footer.php";

// At which record shall we start
$start = isset($_GET['start']) ? intval($_GET['start']) : 0;

$view_category_id = isset($_GET['view_category_id']) ? intval($_GET['view_category_id']) : 0;

$partners_total $smartpartner_partner_handler->getPartnerCount();

if(
$xoopsModuleConfig['index_sortby']== 'title' || $xoopsModuleConfig['index_sortby']== 'weight'){
    
$order 'ASC';
}
else{
    
$order 'DESC';
}
//Retreive all records from database
$every_categories_array $smartpartner_category_handler->getCategories(0,0,-1,'weight''ASC'true);
$every_partners_array $smartpartner_partner_handler->getPartnersForIndex(-1_SPARTNER_STATUS_ACTIVE$xoopsModuleConfig['index_sortby'], $order);

$partnersArray = array();

//display All categories and partners
if(!$view_category_id){
    
//get orphan first if preference says so
    
if($xoopsModuleConfig['orphan_first']){
        
$partnersArray['orphan']['partners']= get_partners_array(0);
    }

    
//get all categories and content
    
foreach ( $every_categories_array as $categoryObj){
        if (
$categoryObj->parentid()==0){
            
$partnersArray[] = get_cat_content($every_categories_array$categoryObj,0);
        }
    }

    
    
//get orphan last if preference says so
    
if(!$xoopsModuleConfig['orphan_first']){
        
$partnersArray['orphan']['partners']= get_partners_array(0);
    }
    
    
$categoryPath '';
}

//viewing a specific category
else{
    
$currentCategoryObj $every_categories_array[$view_category_id];
    
$partnersArray[] = get_cat_content($every_categories_array$currentCategoryObj0);

    if (!
$partnersArray[0]['partners'] && !$partnersArray[0]['subcats']) {
        
redirect_header(SMARTPARTNER_URL3_MD_SPARTNER_CATEGORY_EMPTY);            
    }
    
// Retreiving the category path
    
$categoryPath $currentCategoryObj->getCategoryPath();
}

//$partners_total_onpage = $count;.partners
$xoopsTpl->assign('partners'$partnersArray);

//end new code to implement categories

// Partners Navigation Bar
//$pagenav = new XoopsPageNav($partners_total_onpage, $xoopsModuleConfig['perpage_user'], $start, 'start', '');
//$xoopsTpl->assign('pagenav', '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>');
$xoopsTpl->assign('view_deteils_cat'_MD_SPARTNER_DETAIL_CAT);
$xoopsTpl->assign('on_index_page'$view_category_id == 0);
$xoopsTpl->assign('sitename'$xoopsConfig['sitename']);
$xoopsTpl->assign("displayjoin" $xoopsModuleConfig['allowsubmit'] && (is_object($xoopsUser) || $xoopsModuleConfig['anonpost']));
$xoopsTpl->assign("img_max_width" $xoopsModuleConfig['img_max_width']);
$xoopsTpl->assign('module_home''<a href="' SMARTPARTNER_URL '">' $smartpartner_moduleName '</a>');
$xoopsTpl->assign('categoryPath'$categoryPath);
$xoopsTpl->assign('lang_intro_text' $myts->displayTarea($xoopsModuleConfig['welcomemsg']));
$xoopsTpl->assign('lang_partner'_MD_SPARTNER_PARTNER);
$xoopsTpl->assign('lang_desc'_MD_SPARTNER_DESCRIPTION);
$xoopsTpl->assign('lang_edit'_MD_SPARTNER_EDIT);
$xoopsTpl->assign('lang_delete'_MD_SPARTNER_DELETE);
$xoopsTpl->assign('lang_hits'_MD_SPARTNER_HITS);
$xoopsTpl->assign('lang_join' _MD_SPARTNER_JOIN);
$xoopsTpl->assign('lang_no_partners'_MD_SPARTNER_NOPART);
$xoopsTpl->assign('lang_main_partner'_MD_SPARTNER_PARTNERS);
$xoopsTpl->assign('lang_readmore'_MD_SPARTNER_READMORE);
if(!
$xoopsModuleConfig['hide_module_name']){
    
$xoopsTpl->assign('lang_partnerstitle'$myts->displayTarea($xoopsModule->getVar('name')));
}
include_once 
XOOPS_ROOT_PATH.'/footer.php';
?>


It must have a loop or such thing but I couldn´t find it.
I tried to give you all information. If someone can help me I would apreciate a lot.
Thank you in advanced!!!!

2
Burning
Re: smartpartner and 100% cpu usage by APACHE
  • 2009/12/23 4:12

  • Burning

  • Theme Designer

  • Posts: 1163

  • Since: 2006/8/22


hi'

Quote:
The funniest is that even if i go to another page, the usage of CPU continues.

Just an idea... is there a smartpartner block displayed on all your pages ?

Smartpartner becomes old ... I have read that tommyz is working to update a module called xDirectory

3
ccrstudioweb
Re: smartpartner and 100% cpu usage by APACHE

No,
I´ve just set it as first xoops´page.
I´ll take a look at xDirectory.
But for now I´d like to discover the smartpartner problem! Thank you!

4
ccrstudioweb
Re: smartpartner and 100% cpu usage by APACHE

More information:
I´ve reduced the DB to 4,000 numbers but even so, the CPU usage goes from 10% to 77% when I request smartpartner/index.php

When I request search.php (and its tesult), and partner.php The CPU continues on 11%

There are any error of DB connection on index.php (and its requests).

Its code I´ve showed before, Any one may help me?

5
ccrstudioweb
Re: smartpartner and 100% cpu usage by APACHE

Hi All, I decided to continue using smartfactory 1.4 because it was very good in my localhost but the broblem related. So as I didi´nt discover the problem, I´ve solved it by taking off ALL links to index.php. It means that the user WILL have to use the XOOPS search engine to find the information (partner) he wants.

No more module directory search.

But If someone one day see this and know a tip, stay at home!
Thank you all!!

Login

Who's Online

251 user(s) are online (167 user(s) are browsing Support Forums)


Members: 0


Guests: 251


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits