ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Index.php file causing large server load

August 12, 2012 2:50pm

Subscribe [2]
  • #1 / Aug 12, 2012 2:50pm

    Mike Young

    283 posts

    My host recently shut down one of my 1.72 EE site’s on an MSM (latest) saying that the index.php file was a resource hog. This file has gone unchanged for 4-5 years so I’m not sure what caused the problem. I turned on dynamic caching and it seemed to help but they stated that it was still above average usage. They stated in an email:

    Do note however that there may have been other issues unobserved that may have caused the initial suspension, and that this simply means we trust your efforts will have a positive effect on the account’s performance as a whole. You should still look over your code and databases for other ways to optimize your sites regularly so that this will not happen again in the future.

    Here’s the file in question. Any ideas to help optimize?

    <?php
    /*
    =====================================================
     ExpressionEngine - by EllisLab
    -----------------------------------------------------
     <a href="http://expressionengine.com/">http://expressionengine.com/</a>
    -----------------------------------------------------
     Copyright (c) 2003 - 2008 EllisLab, Inc.
    =====================================================
     THIS IS COPYRIGHTED SOFTWARE
     PLEASE READ THE LICENSE AGREEMENT
     <a href="http://expressionengine.com/docs/license.html">http://expressionengine.com/docs/license.html</a>
    =====================================================
     File: index.php
    -----------------------------------------------------
     Purpose: Triggers the main engine
    =====================================================
    */
    
    // URI Type
    // This variable allows you to hard-code the URI type.
    // For most servers, 0 works fine.
    // 0 = auto  
    // 1 = path_info  
    // 2 = query_string
    
    $qtype = 0; 
    
    
    // DO NOT EDIT BELOW THIS!!! 
    
    error_reporting(0);
    
    if (isset($_GET['URL'])) 
    { 
     /** ---------------------------------
     /**  URL Redirect for CP and Links in Comments
     /** ---------------------------------*/
    
     $_GET['URL'] = str_replace(array("\r", "\r\n", "\n", ':',':','/','/', '
    ', '
    ', ' ', '[removed]'), 
              array('', '', '', ':', ':', '/', '/', '', '', '', ''), 
              $_GET['URL']);
     
     if (substr($_GET['URL'], 0, 4) != "http" AND ! ereg('://', $_GET['URL']) AND substr($_GET['URL'], 0, 1) != '/') 
      $_GET['URL'] = "http://".$_GET['URL']; 
      
     $_GET['URL'] = str_replace( array('"', "'", ')', '(', ';', '}', '{', 'script%', 'script&', '(', ')', '<'), 
            '', 
            strip_tags($_GET['URL']));
     
     $host = ( ! isset($_SERVER['HTTP_HOST'])) ? '' : (substr($_SERVER['HTTP_HOST'],0,4) == 'www.' ? substr($_SERVER['HTTP_HOST'], 4) : $_SERVER['HTTP_HOST']);
     
     if ( ! isset($_SERVER['HTTP_REFERER']) OR ! stristr($_SERVER['HTTP_REFERER'], $host))
     {
      // Possibly not from our site, so we give the user the option
      // Of clicking the link or not
      
      $str = "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>".
        "To proceed to the URL you have requested, click the link below:".
        "<a href="http://.$_GET">".$_GET['URL']."</a>\n</body>\n</html>";
     }
     else
     {
      $str = "<html>\n<head>\n<title>Redirect</title>\n".
          '<meta http-equiv="refresh" content="0; URL='.$_GET['URL'].'">'.
          "\n</head>\n<body>\n</body>\n</html>";
     }
     
     exit($str);
    }
    
    $uri  = '';
    $pathinfo = pathinfo(__FILE__);
    $ext  = ( ! isset($pathinfo['extension'])) ? '.php' : '.'.$pathinfo['extension'];
    $self = ( ! isset($pathinfo['basename'])) ? 'index'.$ext : $pathinfo['basename'];
    
    $path_info = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
    $query_str = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
    
    switch ($qtype)
    {
     case 0 : $uri = ($path_info != '' AND $path_info != "/".$self) ? $path_info : $query_str;
      break;
     case 1 : $uri = $path_info;  
      break;
     case 2 : $uri = $query_str; 
      break;
    }
    
    unset($system_path);
    unset($config_file);
    unset($path_info);
    unset($query_str);
    unset($qstr);
    
    require 'path'.$ext;
    
    if ((isset($template_group) AND isset($template)) && $uri != '' && $uri != '/')
    {
     $template_group = '';
     $template = '';
    }
    
    if ( ! isset($system_path))
    {
     if (file_exists('install'.$ext))
     {
      header("location: install".$ext); 
      exit;
     }
     else
     {
            exit("The system does not appear to be installed. Click <a href="http://install.php">here</a> to install it."); 
     }
    }
    
    if ( ! ereg("/$", $system_path)) $system_path .= '/';
    
    if ( ! @include($system_path.'core/core.system'.$ext))
    {
     exit("The system path does not appear to be set correctly.  Please open your path.php file and correct the path."); 
    }
    
    ?>
  • #2 / Aug 13, 2012 5:50pm

    Kevin Smith

    4784 posts

    Hi Mike,

    It doesn’t look like that’s actually the 1.7.2 version of index.php (which was released in 2012, and you can see the copyright date on this file is through 2008). I would recommend making sure you’re using the 1.7.2 version of the file or, if you can’t find it, upgrading your site to the latest EE 1 release (1.7.3).

    I doubt that’s the problem though. The way EE works is by having all web requests for the front-end come through index.php (think of it like a front door). Once a web request hits index.php, EE then figures out what to serve up based on all the segments that come after index.php in the URL:

    http://example.com/index.php/template_group/template/url_title

    Since all requests for the front-end come through that one file, a server admin just looking at logs might think that particular file is causing all the trouble. In reality, it could be any of the templates or add-ons in EE. Could you get more information from them on the problems they’re detecting?

  • #3 / Aug 18, 2012 3:33am

    Mike Young

    283 posts

    Thanks. I’m trying to get more info from them.

  • #4 / Aug 19, 2012 8:42pm

    Mike Young

    283 posts

    This is what they responded with:

    Hello.

    Thank you for contacting Hostgator.com. We apologize, however reviewing what may have originally caused this is unclear. However, I can give you the cpu usage we saw at the time of the suspension which should be enough..

    Running Proceses:

    —-Pass 1—-
    username 21954 21.0 0.3 291692 30108 ? SN 15:32 0:00 | \_ /usr/bin/php /home/username/public_html/elitetrack-com/index.php
    username 21950 22.0 0.0 0 0 ? ZN 15:32 0:00 | \_ [php] <defunct>
    username 21958 2.0 0.0 11780 936 ? RN 15:32 0:00 \_ /opt/suphp/sbin/limitphp /home/username/public_html/elitetrack-com/index.php
    username 21954 27.0 0.3 292508 30896 ? RN 15:32 0:00 | \_ /usr/bin/php /home/username/public_html/elitetrack-com/index.php
    username 21958 12.0 0.2 282960 21224 ? RN 15:32 0:00 \_ /usr/bin/php /home/username/public_html/elitetrack-com/index.php
    username 21954 32.0 0.0 0 0 ? ZN 15:32 0:00 | \_ [php] <defunct>
    username 21973 8.0 0.2 278732 16600 ? RN 15:32 0:00 | \_ /usr/bin/php /home/username/public_html/elitetrack-com/index.php
    username 21958 19.0 0.3 288340 26612 ? RN 15:32 0:00 \_ /usr/bin/php /home/username/public_html/elitetrack-com/index.php
    username 21954 32.0 0.0 0 0 ? ZN 15:32 0:00 | \_ [php] <defunct>
    username 21973 16.0 0.3 286076 24632 ? RN 15:32 0:00 | \_ /usr/bin/php /home/username/public_html/elitetrack-com/index.php
    username 21958 27.0 0.3 292572 31276 ? RN 15:32 0:00 \_ /usr/bin/php /home/username/public_html/elitetrack-com/index.php

    —-Pass 2—-
    username 22012 21.0 0.3 292088 30456 ? RN 15:32 0:00 | \_ /usr/bin/php /home/username/public_html/elitetrack-com/index.php
    username 22012 29.0 0.4 295164 33548 ? RN 15:32 0:00 | \_ /usr/bin/php /home/username/public_html/elitetrack-com/index.php
    username 22012 38.0 0.4 296188 34848 ? SN 15:32 0:00 | \_ /usr/bin/php /home/username/public_html/elitetrack-com/index.php

    —-Pass 3—-
    username 22094 7.0 0.1 278220 15636 ? RN 15:32 0:00 | \_ /usr/bin/php /home/username/public_html/elitetrack-com/index.php
    username 22094 17.0 0.3 287316 25820 ? RN 15:32 0:00 | \_ /usr/bin/php /home/username/public_html/elitetrack-com/index.php
    username 22094 25.0 0.3 292724 30860 ? RN 15:32 0:00 | \_ /usr/bin/php /home/username/public_html/elitetrack-com/index.php

    —-Pass 4—-
    username 22154 0.0 0.2 279080 17408 ? RN 15:32 0:00 | \_ /usr/bin/php /home/username/public_html/elitetrack-com/index.php
    username 22154 13.0 0.2 283724 21908 ? SN 15:32 0:00 | \_ /usr/bin/php /home/username/public_html/elitetrack-com/index.php
    username 22154 13.0 0.2 283724 21908 ? SN 15:32 0:00 | \_ /usr/bin/php /home/username/public_html/elitetrack-com/index.php
    username 22181 3.0 0.0 54284 468 ? RN 15:32 0:00 | \_ /usr/bin/php /home/username/public_html/elitetrack-com/index.php
    username 22154 13.0 0.2 283724 21908 ? SN 15:32 0:00 | \_ /usr/bin/php /home/username/public_html/elitetrack-com/index.php

     

  • #5 / Aug 20, 2012 4:53pm

    Shane Eckert

    7174 posts

    Hi Mike,

    Unfortunately this does not tell us much. Just CPU usage.

    Can you ask them to look for usage in the Apache logs at the same time? What was going on in Apache’s world when the CPU was being used heavily?

    I wish I could be of more help.

    Cheers,

  • #6 / Aug 20, 2012 9:23pm

    Mike Young

    283 posts

    Here’s what they sent back:

    Total number of unique IP addresses: 489
    Total number of requests: 5291
    Total number of unique request strings: 3305
    Total number of unique referers: 320
    Total number of unique user agents: 232
    Total bandwidth sent in responses: 86M [ 90731799B]

    Top 10 requesting IP Addresses based on count:
    COUNT: 1329 / 25.12% IP: 66.249.73.92 HOST: crawl-66-249-73-92.googlebot.com
    COUNT: 1133 / 21.41% IP: 100.43.83.136 HOST: spider-100-43-83-136.yandex.com
    COUNT: 117 / 02.21% IP: 142.68.227.159 HOST: drmons0505w-142068227159.dhcp-dynamic.FibreOp.ns.bellaliant.net
    COUNT: 78 / 01.47% IP: 60.234.196.33 HOST: mail3.tnz.co.nz
    COUNT: 64 / 01.21% IP: 67.84.61.122 HOST: ool-43543d7a.dyn.optonline.net
    COUNT: 64 / 01.21% IP: 68.13.77.167 HOST: ip68-13-77-167.om.om.cox.net
    COUNT: 58 / 01.10% IP: 24.212.158.105 HOST: 24-212-158-105.cable.teksavvy.com
    COUNT: 58 / 01.10% IP: 82.145.211.7 HOST: z24-08.opera-mini.net
    COUNT: 53 / 01.00% IP: 65.52.104.87 HOST: msnbot-65-52-104-87.search.msn.com
    COUNT: 53 / 01.00% IP: 78.141.137.36 HOST: ip-78-141-137-36.dyn.luxdsl.pt.lu

    Request count distribution per hour of the day:
    Hour: 15 Count: 3755 / 70.97%
    Hour: 16 Count: 1536 / 29.03%

    Request count distribution per day of the week:
    Day: Saturday Count: 5291 / 100.00%

    Request count per hour:
    Hour: 11/Aug/2012:15 Count: 3755 / 70.97%
    Hour: 11/Aug/2012:16 Count: 1536 / 29.03%

    Top 10 Request Strings:
    Count: 185 / 03.50% Request: GET /
    Count: 95 / 01.80% Request: GET /favicon.ico
    Count: 89 / 01.68% Request: GET /scripts/behavior.js.php
    Count: 85 / 01.61% Request: GET /home/rss/
    Count: 77 / 01.46% Request: GET /article_files/relay.pdf
    Count: 46 / 00.87% Request: GET /globals/javascript
    Count: 39 / 00.74% Request: GET /globals/forum.css
    Count: 39 / 00.74% Request: GET /globals/nav.css
    Count: 39 / 00.74% Request: GET /globals/main.css
    Count: 39 / 00.74% Request: GET /globals/Sf.css

    HTTP Response Codes:
    Count: 2533 / 47.87% Code: 200 - OK
    Count: 83 / 01.57% Code: 206 - Partial Content
    Count: 94 / 01.78% Code: 301 - Moved Permanently
    Count: 76 / 01.44% Code: 302 - Moved Temporarily
    Count: 39 / 00.74% Code: 304 - Not Modified
    Count: 2451 / 46.32% Code: 403 - Forbidden
    Count: 15 / 00.28% Code: 404 - Not Found

    Top 10 Referers:
    Count: 3476 / 65.70% Referer: None
    Count: 351 / 06.63% Referer: http://www.elitetrack.com/
    Count: 74 / 01.40% Referer: http://www.elitetrack.com/forums/
    Count: 56 / 01.06% Referer: http://www.elitetrack.com/forums/viewthread/9463/
    Count: 40 / 00.76% Referer: http://www.elitetrack.com/blogs/details/4062/
    Count: 40 / 00.76% Referer: http://www.elitetrack.com/blogs/details/7258/
    Count: 39 / 00.74% Referer: http://www.elitetrack.com/blogs/details/6110/
    Count: 37 / 00.70% Referer: http://www.elitetrack.com/forums/viewthread/10243/
    Count: 36 / 00.68% Referer: http://www.elitetrack.com/forums/viewthread/7504/
    Count: 35 / 00.66% Referer: http://www.elitetrack.com/faqs/answer/221

    Top 10 User Agents:
    Count: 1164 / 22.00% User Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
    Count: 1133 / 21.41% User Agent: Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)
    Count: 311 / 05.88% User Agent: Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)
    Count: 260 / 04.91% User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.75 Safari/537.1
    Count: 146 / 02.76% User Agent: Googlebot-Image/1.0
    Count: 98 / 01.85% User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0.1
    Count: 90 / 01.70% User Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
    Count: 86 / 01.63% User Agent: Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)
    Count: 82 / 01.55% User Agent: Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.75 Safari/537.1
    Count: 82 / 01.55% User Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)

    Top 10 Web Crawlers:
    Count: 1164 / 22.00% Crawler: googlebot
    Count: 1133 / 21.41% Crawler: yandexbot
    Count: 311 / 05.88% Crawler: bingbot
    Count: 86 / 01.63% Crawler: baiduspider
    Count: 17 / 00.32% Crawler: msnbot

    Count per request method:
    Count: 5269 / 99.58% Method: GET
    Count: 20 / 00.38% Method: HEAD
    Count: 2 / 00.04% Method: POST

    Count per HTTP protocol:
    Protocol: HTTP/1.0 Count: 104 / 01.97%
    Protocol: HTTP/1.1 Count: 5187 / 98.03%

    Top 10 Bandwidth Consuming Request Arguments:
    Bandwidth: 9M / 11.19% Request: GET /article_files/relay.pdf
    Bandwidth: 4M / 05.57% Request: GET /article_files/kineticanalysisdiscus.pdf
    Bandwidth: 3M / 03.84% Request: GET /scripts/adpeel/large.jpg
    Bandwidth: 3M / 03.82% Request: GET /article_files/javstrength.pdf
    Bandwidth: 2M / 02.84% Request: GET /images/h2_headers.png
    Bandwidth: 1M / 01.78% Request: GET /article_files/bartonietz-rotational-sp.pdf
    Bandwidth: 1M / 01.60% Request: GET /
    Bandwidth: 1M / 01.60% Request: GET /scripts/jquery.js
    Bandwidth: 1M / 01.36% Request: GET /globals/main.css
    Bandwidth: 801K / 00.90% Request: GET /article_files/explosive-strength.pdf

    Thanks for any assistance you can provide!

  • #7 / Aug 22, 2012 12:08pm

    Shane Eckert

    7174 posts

    Hey Mike,

    Kevin noted above that the version index.php you are using is not correct.

    Can you make sure you have the proper index.php file?

    As to the results, I honestly see nothing wrong. Your site is busy, that’s about it. You may need to upgrade hosting.

    Thank you,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases