Web Hosting Talk







View Full Version : Gazillion includes in a page


grabmail
03-28-2007, 03:53 AM
Assuming you have 50 includes in a PHP script, the page load is going to take some time since there is a lot of disk activity.

However, after installing APC or eaccelerator, does that mean there is no longer any more disk activity for the includes since the included scripts are retrieved directly from memory?

Ks Jeppe
03-28-2007, 04:33 AM
If they are cached, EA or APC will only check the last modified date and check if the page has been modified since last cache, if it hasn't, it'll just read from the RAM...

Or at least, that's how i understood it back when i first started using EA :P

stuffradio
03-28-2007, 02:15 PM
no,

don't use include.... include is a bad choice.

Use require(); or require_once();

Ks Jeppe
03-28-2007, 02:34 PM
stuffradio: You can't comepare include() and require() and generally say that one is better than another, they have totally different returns, and using require instead of include blindly could lead to the OPs scripts not working...

IMO, if the OP is to use anything other than include(), it should be include_once()...

grabmail
03-28-2007, 04:27 PM
hello guys. let's not fight over include, require, include_once etc.

I know the diff b/w them.

Now, i'm just asking whether PHP will read the scripts from disk or from memory during an include() if you install APC

Ks Jeppe
03-28-2007, 07:15 PM
And i believe i answered? :P

RBBOT
03-28-2007, 08:47 PM
It will read from RAM assuming that the size limit you specify for the cache is larger than the compiled size of your scripts - remember the cache holds the compiled version of the script which is typically much larger than the source file.

If there isn't room for all scripts in cache memory the different accelerators have a variety of options on what to do depending on how they are configured. Some will remove such pages from the cache causing them to be recompiled and put back in the cache from disk when they are next hit. Others will keep them in cache and push part of the compiled code into disk instead of RAM which means you keep the precompilation benefits but are reading more bytes from disk than if it was recompiling the source.

mikey1090
03-29-2007, 04:28 PM
would there ever be a situation where 50 files needed to be drawn togethor?

that would be quite un-efficient

grabmail
03-29-2007, 06:09 PM
if you are using a popular PHP framework, you are most likely pushing about 50 includes per page