How do I optimise proddetail.php in ecommerce shop?

Hi I have been asked to 'optimise ’ this file header below. My server keeps blocking all IP’s due to over use of this file. I have no idea why as this file is a part of many other files used in the ecommerce and all other files in the root directory have the same/similar headers. Why only this file?

Server tech said this

Your account “” hosted on is running various CPU intensive php scripts which are causing very high load on the server and due to which server is going under very high load.

Please have a look at the follow details about your php scripts running in parallel.

Top Process %CPU 15.0 /usr/bin/php /home/stixands/public_html/proddetail.php

Top Process %CPU 14.0 /usr/bin/php /home/stixands/public_html/proddetail.php

Top Process %CPU 13.0 /usr/bin/php /home/stixands/public_html/proddetail.php

stixands 605 0.0 0.1 44020 11716 ? S 15:38 0:00 /usr/bin/php /home/stixands/public_html/proddetail.php
stixands 2094 0.0 0.1 44020 11712 ? S 15:39 0:00 /usr/bin/php /home/stixands/public_html/proddetail.php
stixands 2685 0.0 0.1 47356 13900 ? S 15:40 0:00 /usr/bin/php /home/stixands/public_html/proddetail.php
etc etc etc

We had no choice but to block web access of your account to stabilize the server because server is currently under very high load.

Please involve a web developer to check and optimize the code to decrease the resource usage. You should optimize your scripts/queries a little further because we believe that there is always some room for improvement.

Can anyone suggest how to optimise this file?
//Author: Vince Reid, [email protected]

<?php session_cache_limiter('none'); session_start(); ?> <?php include $GLOBALS['HTTP_SERVER_VARS']['DOCUMENT_ROOT']."/vsadmin/db_conn_open.php"; include $GLOBALS['HTTP_SERVER_VARS']['DOCUMENT_ROOT']."/vsadmin/includes.php"; include $GLOBALS['HTTP_SERVER_VARS']['DOCUMENT_ROOT']."/vsadmin/inc/languagefile.php"; include $GLOBALS['HTTP_SERVER_VARS']['DOCUMENT_ROOT']."/vsadmin/inc/incfunctions.php"; include $GLOBALS['HTTP_SERVER_VARS']['DOCUMENT_ROOT']."/vsadmin/inc/metainfo.php"; @include_once $GLOBALS['HTTP_SERVER_VARS']['DOCUMENT_ROOT'].'/twatch_include/logger.php'; ?> Stix and Stones Baby
    <div id="slogan"><img src="images/fresh_and_funky.png" width="328" height="18" alt="fresh and funky keepsakes for mum and bub" /></div>

<div class="box1Pad">

    <div id="navigation">
        <a href="/index.php">home</a>
        <img src="images/bullet.gif" width="7" height="6" alt="" />
        <a href="/meettheteam/">meet the team</a>
        <img src="images/bullet.gif" width="7" height="6" alt="" />
        <a href="/babyography/">babyography&reg;</a>
        <img src="images/bullet.gif" width="7" height="6" alt="" />
        <a href="/babynames/">names for baby</a>
        <img src="images/bullet.gif" width="7" height="6" alt="" />
        <a href="/contact/">contact us</a>
        <img src="images/bullet.gif" width="7" height="6" alt="" />
        <a href="/stockists/">stockists</a>        </div>
<?php include("vsadmin/inc/incsidemenu.php") ?>
<?php include("vsadmin/inc/incminicart.php") ?>
        <div id="babyNameDB" class="box2Top"><div class="box2Left"><div class="box2Right"><div class="box2Bot">
        <div class="box2TopLeft"><div class="box2TopRight"><div class="box2BotLeft"><div class="box2BotRight">
        <div class="pad4" >
            <h1 class="pad8">BABY NAME</h1>
            <h1 class="pink">database</h1>
            <div class="go2"><a href="/babynames/babynames.php"><img src="images/go2.gif" width="20" height="20" alt="GO" /></a></div>
        <div class="hr2">&nbsp;</div>

        <div id="subscribeBox" class="box2Top"><div class="box2Left"><div class="box2Right"><div class="box2Bot">
        <div class="box2TopLeft"><div class="box2TopRight"><div class="box2BotLeft"><div class="box2BotRight">
        <div class="pad9" >
            <a class="subscribeGo" href="/newsletter/"><img src="images/go2.gif" width="20" height="20" alt="GO" /></a>

to our quarterly newsletter

        <?php include $GLOBALS['HTTP_SERVER_VARS']['DOCUMENT_ROOT']."/vsadmin/inc/nav/incbc.php"; ?>
        <!-- InstanceBeginEditable name="mainContent" --><?php include "vsadmin/inc/incproddetail.php" ?><!-- InstanceEndEditable -->                   
        <div id="searchBox">
       <p class="pad3">SEARCH THE SITE</p>
        <a class="startShopping" href="categories.php"><img src="images/start_shopping.gif" width="140" height="28" alt="START SHOPPING" /></a>

        <p class="copyright">
        &copy;2007 Stix and Stones Baby. All rights reserved.<br />

Babyography® is a registered trademark of Tracey Donaghey.

        <div class="clear">&nbsp;</div>

        <div class="footerLinks">

Customer Care |
Ordering & Delivery |
Privacy & Security |
Copyright |
Terms & Conditions |
Faq’s |

This file is not the issue, it’s one of the includes that it uses to pull the product detail from your database.

Either that query needs to be optimized or the database needs to be optimized…

Neither of which you are showing us.

Also, nothing comes up for

So I can’t even see what e-commerce platform you’re using.

As topcoder said this is not a single file problem. The solution you are using seems to be a quite small one (one man team that has developed it?), which again seems to mean there have been some shortcuts. Judging on some code snippets that have come up online searching the authors email shows lack of safe parameterized database queries, lack of cache-usage, etc. The first one is important for your sites security, the second one might be the problem here.

It’s amazing to see how much resources a webapp with a few hundread users can use, but simply by using cache the amount of concurrent users can be 100x higher and still give a lower server load.

In my mind the solutions for this is either

keep the current solution

  1. get the current solution upgraded (security + speed)
  2. if that doesn’t help, get a bigger server package / traffic control (cloudflare?)

or get something else:

  1. migrate to a new and better solution
  2. buy a webshop saas (software as a service)

Topcoder: you should check out :wink:

Wow what an excellent response. My deepest sincere gratitude to both.

You can’t see the site because Server Techs locked tall the IPs.
You are correct this was done by one man (not me) with customized mods to the existing eCommerce.

I am trying to convert my client to Zencart but now ‘her neighbor’ recommended to use WordPress with shop plugins. She has 1000’s of products and 100’s categories. I can see other problems there.

Original programmer no longer exists. I already optimised the database tables (not queries). She is already on a bigger package hosting.

If you are suggesting that one of these includes might be causing the problem then at least I can start looking at them. Or even post them here :o

include $GLOBALS[‘HTTP_SERVER_VARS’][‘DOCUMENT_ROOT’]."/vsadmin/db_conn_open.php";
include $GLOBALS[‘HTTP_SERVER_VARS’][‘DOCUMENT_ROOT’]."/vsadmin/includes.php";
include $GLOBALS[‘HTTP_SERVER_VARS’][‘DOCUMENT_ROOT’]."/vsadmin/inc/languagefile.php";
include $GLOBALS[‘HTTP_SERVER_VARS’][‘DOCUMENT_ROOT’]."/vsadmin/inc/incfunctions.php";
include $GLOBALS[‘HTTP_SERVER_VARS’][‘DOCUMENT_ROOT’]."/vsadmin/inc/metainfo.php";
@include_once $GLOBALS[‘HTTP_SERVER_VARS’][‘DOCUMENT_ROOT’].’/twatch_include/logger.php’; ?>

I didn’t even think of that @JimL. That’s why I’m still the student!


I would say it’s most likely this one…

<?php include "vsadmin/inc/incproddetail.php" ?>


Actually what you should do is enable the MySQL Slow query logs, if it’s not already and it will show you all the sql statements that are taking a long time to run…

Sponsor our Newsletter | Privacy Policy | Terms of Service