Httpd huge usage

Hello,

Since one week my httpd processes use near 100% of cpu usage.

The box is a PIV 3.0 Ghz with 1Go of ram.

There is only 6 siteworx accounts on this box, and it is true than 2 of them are high usage siteweb. But the httpd cpu use is even high when there is not a lot of http connexion.

For exemple, now I have for a :

netstat -n | grep :80 |wc -l
54

and as syn

netstat -n | grep :80 | grep SYN |wc -l
0

I have no error in /var/log/httpd/error_log

Also I have disabeld all no default config as mod_security for example. I have also reisntalled the default php interworx rpms

So now I have a default interowrx install.

At least I have always ONE process taking 50%

PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND
21952 apache 25 0 30228 29M 9828 R 49.5 2.9 1:00 0 httpd

When I look at the server-statut I may see that the process that take a high cpu usage are variying

24-0 - 0/0/11 . 67.82 26 19 0.0 0.00 0.05 84.101.151.43 emule-zenzone.com GET /modules/dbcounter/cache/cpt.php HTTP/1.1

25-0 - 0/0/24 . 64.70 25 0 0.0 0.00 3.58 83.134.0.6 emule-zenzone.com GET /images/rss.png HTTP/1.1

29-0 - 0/0/35 . 61.40 22 0 0.0 0.00 0.07 81.192.199.251 emule-zenzone.com GET /images/language/spanish.gif HTTP/1.1

Sometimes it is a get from image file, but also GET to a php and I even see a GET to a robot.txt that did take 80% of CPU

Now I don’t know what to do.
I’ve checked all what I knew.

Some helps will be very usefull

Thanks

Pascal

------- EDITED ----
It seems that all site that have a High usage are website that use a LOT of urlrewrites rules !!!

It seems that all site that have a High usage are website that use a LOT of urlrewrites rules !!!

Those can definitely tax the system Pascal, did disabling them ‘fix’ the problem?

Chris

Chris,

What should be the better solution to disable the rwrite rule ?

Disabled the rewrite module or change the vhost conf file ?

I afraid to disable the rewrite module as it is used in all vhost conf files

Pascal

In fact, it seems that the problem come from only one site.

Indeed, when I do

strace -p xxx

of the pid(s) that are using a lot of CPU I always have the same contents

In fact when I do a strace -p xxx of the pid that use a high usage of cpu I always have the same contents :

getcwd("/home/phpbbnet/php-bb.net/html/fr", 4096) = 34 lstat64("/home", {st_mode=S_IFDIR|0711, st_size=4096, …}) = 0 lstat64("/home/phpbbnet", {st_mode=S_IFDIR|S_ISGID|0751, st_size=4096, …}) = 0 lstat64("/home/phpbbnet/php-bb.net", {st_mode=S_IFDIR|S_ISGID|0711, st_size=4096, …}) = 0 lstat64("/home/phpbbnet/php-bb.net/html", {st_mode=S_IFDIR|S_ISGID|0755, st_size=4096, …}) = 0 lstat64("/home/phpbbnet/php-bb.net/html/fr", {st_mode=S_IFDIR|S_ISGID|0755, st_size=4096, …}) = 0 getcwd("/home/phpbbnet/php-bb.net/html/fr", 4096) = 34 lstat64("/home", {st_mode=S_IFDIR|0711, st_size=4096, …}) = 0 lstat64("/home/phpbbnet", {st_mode=S_IFDIR|S_ISGID|0751, st_size=4096, …}) = 0 lstat64("/home/phpbbnet/php-bb.net", {st_mode=S_IFDIR|S_ISGID|0711, st_size=4096, …}) = 0 lstat64("/home/phpbbnet/php-bb.net/html", {st_mode=S_IFDIR|S_ISGID|0755, st_size=4096, …}) = 0 lstat64("/home/phpbbnet/php-bb.net/html/fr", {st_mode=S_IFDIR|S_ISGID|0755, st_size=4096, …}) = 0 lstat64("/home/phpbbnet/php-bb.net/html/fr/includes", {st_mode=S_IFDIR|S_ISGID|0755, st_size=4096, …}) = 0 lstat64("/home/phpbbnet/php-bb.net/html/fr/includes/functions_mods_settings.php", {st_mode=S_IFREG|0644, st_size=5015, …}) = 0 open("/home/phpbbnet/php-bb.net/html/fr/includes/functions_mods_settings.php", O_RDONLY) = 32 fstat64(32, {st_mode=S_IFREG|0644, st_size=5015, …}) = 0 fstat64(32, {st_mode=S_IFREG|0644, st_size=5015, …}) = 0
lseek(32, 0, SEEK_CUR) = 0
lseek(32, 0, SEEK_SET) = 0
close(32) = 0

Etc…

Always a read of /home/phpbbnet/php-bb.net/html/fr/includes/functions_mods_settings.php

I’ve checked this and it is readable by all, so I do not understand

Maybe you have an idea.
Also, this client told me than since few days his webiste doesn’t work anymore (a blank page without any error, I’ve checked)

All the pid that are using a huge CPU usage has this contents, so apparently the pbm come from this website and in particular this functions_mods_settings.php

There is nothing special in this php file :


<?php

/***************************************************************************
 *                            functions_mods_settings.php
 *                            ---------------------------
 *      begin                   : 10/08/2003
 *      copyright               : Ptirhiik
 *      email                   : admin@rpgnet-fr.com
 *      version                 : 1.0.4 - 26/09/2003
 *
 ***************************************************************************/
/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

// some standard lists
$list_yes_no = array('Yes' => 1, 'No' => 0);
define('BOARD_ADMIN', 98);

//---------------------------------------------------------------
//
//      mods_settings_get_lang() : translation keys
//
//---------------------------------------------------------------
function mods_settings_get_lang($key)
{
        global $lang;
        return ( (!empty($key) && isset($lang[$key])) ? $lang[$key] : $key );
}

//---------------------------------------------------------------
//
//      init_board_config_key() : add a key and its value to the board config table
//
//---------------------------------------------------------------
function init_board_config_key($key, $value, $force=false)
{
        global $db, $board_config;

        if (!isset($board_config[$key]))
        {
                $board_config[$key] = $value;
                $sql = "INSERT INTO " . CONFIG_TABLE . " (config_name,config_value) VALUES('$key','$value')";
                if ( !$db->sql_query($sql) ) message_die(GENERAL_ERROR, 'Could not add key ' . $key . ' in config table', '', __LINE__, __FILE__, $sql);
        }
        else if ($force)
        {
                $board_config[$key] = $value;
                $sql = "UPDATE " . CONFIG_TABLE . " SET config_value='$value' WHERE config_name='$key'";
                if ( !$db->sql_query($sql) ) message_die(GENERAL_ERROR, 'Could not add key ' . $key . ' in config table', '', __LINE__, __FILE__, $sql);
        }
}

//---------------------------------------------------------------
//
//      user_board_config_key() : get the user choice if defined
//
//---------------------------------------------------------------
function user_board_config_key($key, $user_field='', $over_field='')
{
        global $board_config, $userdata;

        // get the user fields name if not given
        if (empty($user_field))
        {
                $user_field = 'user_' . $key;
        }

        // get the overwrite allowed switch name if not given
        if (empty($over_field))
        {
                $over_field = $key . '_over';
        }

        // does the key exists ?
        if (!isset($board_config[$key])) return;

        // does the user field exists ?
        if (!isset($userdata[$user_field])) return;

        // does the overwrite switch exists ?
        if (!isset($board_config[$over_field]))
        {
                $board_config[$over_field] = 0; // no overwrite
        }

        // overwrite with the user data only if not overwrite sat, not anonymous, and logged in
        if (!intval($board_config[$over_field]) && ($userdata['user_id'] != ANONYMOUS) && $userdata['session_logged_in'])
        {
                $board_config[$key] = $userdata[$user_field];
        }
        else
        {
                $userdata[$user_field] = $board_config[$key];
        }
}

//---------------------------------------------------------------
//
//      init_board_config() : get the user choice if defined
//
//---------------------------------------------------------------
function init_board_config($mod_name, $config_fields, $sub_name='', $sub_sort=0, $mod_sort=0, $menu_name='Preferences', $menu_sort=0)
{
        global $mods;

        @reset($config_fields);
        while ( list($config_key, $config_data) = each($config_fields) )
        {
                if (!isset($config_data['user_only']) || !$config_data['user_only'])
                {
                        // create the key value
                        init_board_config_key($config_key, ( !empty($config_data['values']) ? $config_data['values'][ $config_data['default'] ] : $config_data['default']) );
                        if (!empty($config_data['user']))
                        {
                                // create the "overwrite user choice" value
                                init_board_config_key($config_key . '_over', 0);

                                // get user choice value
                                user_board_config_key($config_key, $config_data['user']);
                        }
                }

                // deliever it for input only if not hidden
                if (!$config_data['hide'])
                {
                        $mods[$menu_name]['data'][$mod_name]['data'][$sub_name]['data'][$config_key] = $config_data;

                        // sort values : overwrite only if not yet provided
                        if (empty($mods[$menu_name]['sort']) || ($mods[$menu_name]['sort'] == 0) )
                        {
                                $mods[$menu_name]['sort'] = $menu_sort;
                        }
                        if (empty($mods[$menu_name]['data'][$mod_name]['sort']) || ($mods[$menu_name]['data'][$mod_name]['sort'] == 0) )
                        {
                                $mods[$menu_name]['data'][$mod_name]['sort'] = $mod_sort;
                        }
                        if (empty($mods[$menu_name]['data'][$mod_name]['data'][$sub_name]['sort']) || ($mods[$menu_name]['data'][$mod_name]['data'][$sub_name]['sort'] == 0) )
                        {
                                $mods[$menu_name]['data'][$mod_name]['data'][$sub_name]['sort'] = $sub_sort;
                        }
                }
        }
}


If you have any ideas, they are welcome :wink:

Pascal

Without debugging the PHP code Pascal I can say that it could be many things (large files being read, tons of DB calls or any other resource intensive task). I’d ask the software authors if they’ve had similar problems with their scripts and they shoudl be able to narrow it down.

We will check out the ‘account disable’ issue you noted in your ticket as well.

Chris

ok thanks Chris