Paris,
Le 20 Feb 2008,
Dear all,
Receiving too much non-qualified traffic : we must apply some advises
from PHP & MySQL experts.
Did you have the chance to embeed your server and apps to ensure the
good treatment of incoming connections ?
From your knowhow and scientific knowledge would you accept to give
some remarks or advises ?
[1] Use a profiler like XDebug to find bottlenecks in the code.
BOB To-do
[2] Check the DB to make sure your tables are properly indexed (you
can use EXPLAIN SELECT ... to get a query analysis).
BOB To-do
*[3] Don't use SELECT *, only fetch the data you really need.
BOB : What better ? to restrict on one column or by multiple columns
if applicable.
e.g : select email from T1 |or| select email with TLD column = COM
[4] Use prepared statements and re-use them if possible.
OK
*[5] Make your content cacheable by sending appropriate HTTP headers.
BOB : I did not understand "sending appropriate HTTP headers". Seems
to be quite smart, but I apologize I did not understand.
[6] Cache content on the server to avoid re-creation over and over
again, for example if you should create images on-the-fly.
OK
[7] Reduce the number of HTTP requests and roundtrips to the server.
OK + BOB To-do
*[8] Use HTTP compression for your text content (HTML, CSS, JS).
BOB : Is it compression as Mr Lemos (CPU impact) : (http://
http://www.phpclasses.org/blog/post/...ith-COMET.html)
Or is it compression from the H.P. of that website
http://www.gogole.com
that is 5 lines long !
*[9] Question : How Google gets a 5 line H.P.
If I view
http://www.gogole.com home page, there are 5 lines. Is that
possible to make that ?
*[10] don't use images that are downloaded at a greater size than yu
need for display purposes, and i possible dont get thenm out of the
database at greater size than they need be.
BOB : OK, but our images are a big-big pb for the brandwidth
*[11] If on a Unix Linux platform examine page swapouts to see if you
are using more memory than you have allocated.
*[12] consider using a server like Zeus if you are seeing a huge
amount of httpd processes.Zeus - if its still around - was
multithreaded and used far less processor time/RAM to serve multiple
connections.
BOB : One of our server is not multi-thread. Hosting provider has
increased prices by 60% since last the 2 mergers.
http://www.valueweb.com/dedicated/dsLinux.htm
BOB to finance J.P. Morgan M&A consulting fees.
*[13] Use queue table (from phpclasses)
BOB : Ok but Is that possible to use web-compression for images ?
CPU ?
[14] Use different partition for Web, mail and database servers
[15] set query-cache-type = 1
OK
*[16] If you have queries which are repeated many times, you can cache
the query results in $_SESSION.
BOB : To do but have no idea how to develop this highly interesting
advice.
Please, I thank you very much for your advices.
Bob Cougloff
Ref : Group Experts Micha, Philosophe, + Sir Lemos + ....
(
http://www.phpclasses.org/blog/post/...e-programming-
practices-to-survive-Web-site-traffic-peaks.html)