if it's the simple stuff like variable substitution and simple loops, php is actually not too bad IMO. When you start doing database and http calls then your performance gets a lot worse.
A static page is obviously going to be faster though.
It depends on the time that your database query or http call takes, and how much data you are returning, and how much processing you have to do on it. A well written query or call won't have too much of a negative impact, maybe making the page two times slower than a static. A poorly written query strategy could make a page a thousand times slower.
in php, you can output the time it takes to complete a given task.
Unfortunately, you can't do this with HTML.
However, you could set the timer in php, and then compare having php build the html vs the php page outputting the html.
That way you are also only comparing the time it takes for php to load the difference, and not differences in how web servers deal with different mime-types, etc.
I suspect you are talking in the less than 1 millisecond range difference though.
If you are asking about this because you are concerned about processor load affecting the number of clients that can connect, in Apache 2.2 the amount of memory and the Apache settings will have some bearing on this also.
For instance, the Apache MaxClients setting formula many follow is, MaxClients = Total RAM dedicated to the web server / Max child process size.
Child process size for serving static file is about 2-3M. For dynamic content such as PHP, it may be around 15M. More memory = more connections.
Apache server performance can be improved by adding additional hardware resources such as RAM, faster CPU etc. but you might be able to achieve the same results with some simple custom Apache configurations on your current setup.
5 comments
[ 3.0 ms ] story [ 21.1 ms ] threadA static page is obviously going to be faster though.
It depends on the time that your database query or http call takes, and how much data you are returning, and how much processing you have to do on it. A well written query or call won't have too much of a negative impact, maybe making the page two times slower than a static. A poorly written query strategy could make a page a thousand times slower.
xdebug and timing code are helpful.
However, you could set the timer in php, and then compare having php build the html vs the php page outputting the html.
That way you are also only comparing the time it takes for php to load the difference, and not differences in how web servers deal with different mime-types, etc.
I suspect you are talking in the less than 1 millisecond range difference though.
For instance, the Apache MaxClients setting formula many follow is, MaxClients = Total RAM dedicated to the web server / Max child process size.
Child process size for serving static file is about 2-3M. For dynamic content such as PHP, it may be around 15M. More memory = more connections.
Apache server performance can be improved by adding additional hardware resources such as RAM, faster CPU etc. but you might be able to achieve the same results with some simple custom Apache configurations on your current setup.
Here is a link for Apache 2.2.3 if you are interested: http://cloudservers.rackspacecloud.com/index.php/Configuring...