Forum Moderators: coopster
I have a VPS containing some domains of mine. Each will get some data from a central database using a php file that contains the queries.
At the moment i do it as follows:
print include($PATH_TO_CENTRAL_FILE.'?param=$param');
The file at $PATH_TO_CENTRAL_FILE will get text from the database which will then be printed directly onto the page.
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.
I must note that i tried to place a similar file (which sent back data, but didn't poll a database) in the same folder as the Webpage. Then i called the function in that file, and this gave much better speeds.
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
include(afile.php);
and then call
print myFunctionInFile($params);
Do I make any sense at all? And if so, does anybody know a way to speed things up?
Thanks in advance!
Evarest
I'm also curious why you don't just query the database right in the script.
Anyway, I hope this speeds things up for you ;)
print include(http://www.mydomain.com/.../afile.php?params=$params);
instead of
include(afile.php);
and then call
print myFunctionInFile($params);
This file only contains a function that polls the Google Adsense site to get an advert from it. Ie you can give in the size/orientation etc of the advert and Google will return the actual advertisement.
Thus, this file doesn't do any database polling on my DB (only that one on google's servers) and the file has no real impact on the speed of the webpage if I use it directly on my webpage? (!?)
The idea of all this work is to centralize the database of my website. This because the database is too large to be copied to each of the domains... Also, it's for maintenance purposes for each of these PHP files (it's easier to change 1 file than a lot of files each on different domains)...
Thanks a lot for your help!
Evarest