Jump to content

The Best PHP Performance Tweaks, Period.


GreenLED

Recommended Posts

I am searching for the definitve answer to squeezing as much performance as I can out of PHP. I'm speaking specifcally about script execution time. I have already adopted a number of suggestions, including trading off PRINT for ECHO. That change alone saved me considerable time in the script execution (at least it felt like the page was actually breathing better). However, I am now faced with anew dilemma. I have changed over to a new server, which I have much more control over, i.e. php.ini. I am looking to seriously squeeze as much performance as I can out of PHP. I am not happy with the delay the script execution is causing to my site. Here's specically the type of stuff I'm looking for. We've all seen the neat php.ini flags you can change to adjust the performance a bit. I'd like to build a definitive and complete listing of all the available tweaks and apply them to my production site. I'd also like as much input as I can get on those type of small changes that make a big difference in script execution time. Thus far I have been able to find a number of good tweaks, but it's not enough. I'm using PHP 5.2.6, with Apache 2. If anyone would happen to have any suggestions on Apache http.conf suggestions I'd be delighted to see those as well -- specifically the settings you'd apply to the following directives if you were running Apache on a 512 MB (RAM) server with a 2.00 GHz processor.

 

<IfModule prefork.c>

StartServers        1

MinSpareServers    2

MaxSpareServers    30

ServerLimit        50

MaxClients        300

MaxRequestsPerChild 4000

</IfModule>

 

<IfModule worker.c>

StartServers        1

MinSpareThreads    2

MaxSpareThreads    30

ThreadsPerChild    50

MaxClients        300

MaxRequestsPerChild 0

</IfModule>

 

I do NOT have a good understanding of how httpd runs, how it creates child processes, etc. I can get the jargon (at least some of the time), but I need some graphical representation of how it works --- or just some suggestions on what values these should be set too.

 

My first post and I'm overloading you guys already . . . OH well, at least I'm keeping you all on your toes.  ;)

Link to comment
https://forums.phpfreaks.com/topic/117059-the-best-php-performance-tweaks-period/
Share on other sites

I have already adopted a number of suggestions, including trading off PRINT for ECHO. That change alone saved me considerable time in the script execution (at least it felt like the page was actually breathing better).

 

The print vs echo debate has been covered allot over the years. In the perfect environment, with nothing else running, you will notice a 3 to 8 milli second difference between the two.

http://www.raditha.com/blog/archives/000407.html

 

As far as performance goes, install a php optimizer like zend or eAccelerator.

 

Focus on security not horsepower. You will have more free time to enjoy the fruits of your labor…

 

chad101 ...

The print vs echo debate has been covered allot over the years. In the perfect environment, with nothing else running, you will notice a 3 to 8 milli second difference between the two.
I approve your reasoning here. In addition I would add that the "perfect" environment will probably never be available (at least not in my lifetime) therefore one can only hope to achieve "perfection" or some increase in performance by adding up all of the small enhancements. Therefore, I would conclude that using ECHO vs PRINT is a beneficial practice. This is especially true if you have a large script that is being executed multiple times in various loops and such. Let me know your thoughts on this.

 

As far as performance goes, install a php optimizer like zend or eAccelerator.
I would need some "hand-holding" as far as installing an app in linux. My work in linux is very limited. As far as Windows goes though, too much experience, lol! Maybe a reference guide of some kind would help me out here. Also, I'd like to choose an OPcode that capitalizes on CPU more and not so much on memory. This is because of my 512 MB limit. It is sometimes a VERY good thing to have limitations. It causes you to think twice about what you're doing and almost always generates an end product that is better than the competition. Granted 512 MB is a limitation that I really am not so excited about, but it's reality and I've got to work around it.

 

Focus on security not horsepower. You will have more free time to enjoy the fruits of your labor...
Your comment here is appreciated. Although my primary concern at the moment is performance, I realize and respect the timing of this comment. In any event, there is a drawback to my knowledge of coding. This being, my tendencies are more towards creating efficient and fast performing execution, not necessarily security. Usually, I have some other app take care of this. In order to become security-aware a ground knowledge of the foundations of PHP must be established, how it operates, it's internal workings, etc. I don't yet have such an advanced knowledge of PHP to achieve this goal.

 

awpti ...

APC is my opcode cache of choice.
Why do you like APC so much? How does it stand up against other OPcodes? Is it O-S (Open Source)?

Archived

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

×
×
  • Create New...

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.