Jump to content


This topic is now archived and is closed to further replies.


Very slow remotely included php functions

Recommended Posts

Hi there!

I have a VPS containing some domains of mine. Each domain will only be able to see it's own dedicated space (folders) on the server.  Also, each will get some data from a central database using a php file that contains the queries. This database is located on a dedicated domain, and cannot be directly polled by any of the other domains. This because the database is too large to be copied to every domain.

To get text from the database (poll the database), i use a script located on that central domain (with the database). This PHP script is called as follows:

print include($PATH_TO_CENTRAL_FILE.'?param=$param');

$param will give the necessary information to the database (will be put in the query) to get the data from it. The data that the file gets from the database will be send back to the resp. webpage and printed there.

When i ran the webpage on the domain, i noticed that it's very slow. Now I ran the linux command ab (Apache Benchmarking) on this webpage. Here are the results for different scenarios:

Without database polling, without the include (the file at $PATH_TO_CENTRAL_FILE is not used at all in the webpage):

137.36 #/sec

The file will only return text, no database polling (no queries run on the database):

0.73 #/sec

The file will poll the database, but not return any results (the webpage gets an empty string):

0.96 #/sec

The file will poll the database and send the results to the webpage (normal scenario):

0.79 #/sec

It appears that whenever I send data back from an included PHP file, the webpage gets incredibly slow. Notice that the webpage still is very slow if i do not poll the database (no query is executed)! (?!)

Therefore, I think it has something to do with the way that inclusions of different (absolute) paths are handled by PHP versus calling a procedure inline your html code. If you include a file using

print include(http://www.mydomain.com/.../afile.php?params=$params);

seems to be a lot slower than

and then call
print myFunctionInFile($params);

with afile.php in the same folder as the webpage.

Do I make any sense at all? And if so, does anybody know a way to speed things up?

Thanks in advance!

Share this post

Link to post
Share on other sites
Thank you for your suggestions! However it didn't work... It's still as slow as before... Any other suggestions?

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.