Results 1 to 13 of 13
  1. #1

    PHP includes increasing server load?

    I run a website which receives about 2k visitors per day, and I use multiple PHP includes (about 10-15) on pages to call in code where I need it in order to keep the code clean and easy to maintain.
    I however started noticing recently that number of executions is in rise, and I'm looking for an advice could the number of includes which I have on pages increase server load? Would combining some of those includes help reduce the load? I'm on a shared hosting environment and load could become an issue.


  2. #2
    Join Date
    Jun 2009
    BD Web Services | Since 2009
    Linux & Windows Hosting | Master Reseller Hosting | Remote Backup | Money Back Guarantee | DDOS Protected | USA & Germany
    Web and SEO Tools cPanel/WHM Proxy, DNS, SEO, GEO, QR Code, Website information AT-A-GLANCE

  3. #3
    Join Date
    Jan 2010
    First, make sure you use file based includes instead of URL based includes. URL based includes in PHP are extremely slow, even if the URL is local. The file based includes are generally pretty fast.

    Also, remember that the less work you ask a computer to do, the less time will be needed to do it. If you currently have 15 includes and you can reduce that to 5 includes, the 5 includes will be faster than the 15 includes.
    No Support Linux Hosting Bargain cPanel Hosting Experts Only
    We IGNORE the support questions, and pass the SAVINGS on to YOU!
    We also ignore questions about VPS Hosting

  4. #4
    No, on healthy hard drive and filesytem includes itself can not increase server load. Make sure that's not slow mysql queries. Check the code. Try to exclude included files one by one to see which file can cause that.
    Let us know more details, if you need more detailed help

  5. #5
    Join Date
    Mar 2013
    If possible reduce their number.

    You can also do without the _once just make sure you include them once only.

    Having said that don't expect any noticeable improvement.

  6. #6
    Join Date
    Nov 2004
    Quote Originally Posted by gingir View Post
    If possible reduce their number.

    You can also do without the _once just make sure you include them once only.

    Having said that don't expect any noticeable improvement.
    Adding the _once would cause some more runtime overhead as some checks need to happen to ensure they are only included once.
    That being said, includes would cause some high IO (we are talking if you are doing LOOTS of them). But I dont think this is what is causing the server load in your case.

  7. #7
    Join Date
    Sep 2013
    On Earth
    file based includes not increase load. Your server load maybe due to DB or bad coding. Recheck your code.
    Looking around for some time
    PM me for Website Design and Web Development Work.

  8. #8
    1. most problems usially made ineffective database queris which not match indexes , or waste resources running when not need .

    2. bad coding , code run when not need

    3. includes take some time to compile , but this is low amount of processor time .

    4. usially 2000/day is low pressure to the server .
    << Please review signature guidelines >>

  9. #9
    I would maybe look into autoloading/namespacing some of what you are doing. Includes that are not used would definitely be eating into the cost of the page load. If your page uses all the includes everytime, then I doubt it will make much of a difference. Like others have said, look at other reasons why the site is slow, particularly the database and indices that you are using in your code.
    Managed Service Provider -
    Public & Private Cloud
    Solutions | SSD SANs | High IOP's | CDN Solutions
    Phoenix/Chandler AZ Colocation | 48U Cabinets | Data Halls | TIA-942 Tier 4 Facility

  10. #10
    Join Date
    Aug 2001
    Quote Originally Posted by xuid View Post
    No, on healthy hard drive and filesytem includes itself can not increase server load.
    I'd second this. - Is your site up?
    Multi-Location Service Availability Check ● the only with support for HTTPS & IDN

  11. #11
    Join Date
    Jul 2012
    Charlotte, NC, US
    Yup url based are very slow to use instead you can use <?php include'./folder/filename.php'; ?>

  12. #12
    You could use a rudimentary profiler to check how long a segment of code is taking.

    At the start of your script:
    <?php $_now = microtime(true); $_time = function() use ($_now) { $end = microtime(true); print ($end-$_now) . " seconds"; }; ?>
    Just add $_time(); after a statement to narrow your selection from there. This works with PHP 5.3+.

  13. #13
    1. Make sure you are not including a URL, specially if URL is pointed to same host.
    2. Check the IO availability of the server. Sometimes too much IO or low memory can cause a lot of problems in PHP includes.

Similar Threads

  1. SSI includes and server load
    By laur in forum Web Design and Content
    Replies: 3
    Last Post: 03-21-2011, 01:51 PM
  2. how many domains can you put on a server without increasing load?
    By systemadminjobs in forum Running a Web Hosting Business
    Replies: 10
    Last Post: 12-16-2010, 09:55 PM
  3. my site very slow without increasing load
    By moheballah in forum Dedicated Server
    Replies: 9
    Last Post: 10-16-2010, 09:33 PM
  4. php 'includes' issue on linux server with apache 2.0.63 / php 5.2.6
    By scotch333 in forum Hosting Security and Technology
    Replies: 5
    Last Post: 06-19-2008, 07:18 AM
  5. the system load increasing suddenly
    By kencash in forum Hosting Security and Technology
    Replies: 9
    Last Post: 05-23-2005, 07:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts