Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>General</strong></p> <ul> <li>Do not try to optimize before you start to see real world load. You might guess right, but if you don't, you've wasted your time. </li> <li>Use <a href="http://jakarta.apache.org/jmeter/" rel="noreferrer">jmeter</a>, <a href="http://www.xdebug.org/" rel="noreferrer">xdebug</a> or another tool to benchmark the site. </li> <li>If load starts to be an issue, either object or data caching will likely be involved, so generally read up on caching options (memcached, MySQL caching options)</li> </ul> <p><strong>Code</strong></p> <ul> <li>Profile your code so that you know where the bottleneck is, and whether it's in code or the database</li> </ul> <p><strong>Databases</strong></p> <ul> <li>Use <a href="http://www.php.net/mysqli" rel="noreferrer">MYSQLi</a> if portability to other databases is not vital, <a href="http://www.php.net/pdo" rel="noreferrer">PDO</a> otherwise</li> <li>If benchmarks reveal the database is the issue, check the queries before you start caching. Use <a href="http://dev.mysql.com/doc/refman/5.0/en/explain.html" rel="noreferrer">EXPLAIN</a> to see where your queries are slowing down.</li> <li>After the queries are optimized and the database is cached in some way, you may want to use multiple databases. Either replicating to multiple servers or sharding (splitting the data over multiple databases/servers) may be appropriate, depending on the data, the queries, and the kind of read/write behavior.</li> </ul> <p><strong>Caching</strong></p> <ul> <li>Plenty of writing has been done on caching code, objects, and data. Look up articles on <a href="http://www.php.net/apc" rel="noreferrer">APC</a>, <a href="http://www.zend.com/en/products/guard/optimizer/" rel="noreferrer">Zend Optimizer</a>, <a href="http://www.danga.com/memcached/" rel="noreferrer">memcached</a>, <a href="http://sourceforge.net/projects/quickcache" rel="noreferrer">QuickCache</a>, <a href="http://www.polarlava.com/projects/jpcache/" rel="noreferrer">JPCache</a>. Do some of this before you really need to, and you'll be less concerned about starting off unoptimized.</li> <li>APC and Zend Optimizer are opcode caches, they speed up PHP code by avoiding reparsing and recompilation of code. Generally simple to install, worth doing early.</li> <li>Memcached is a generic cache, that you can use to cache queries, PHP functions or objects, or entire pages. Code must be specifically written to use it, which can be an involved process if there are no central points to handle creation, update and deletion of cached objects.</li> <li>QuickCache and JPCache are file caches, otherwise similar to Memcached. The basic concept is simple, but also requires code and is easier with central points of creation, update and deletion.</li> </ul> <p><strong>Miscellaneous</strong></p> <ul> <li>Consider alternative web servers for high load. Servers like <a href="http://www.lighttpd.net/" rel="noreferrer">lighthttp</a> and <a href="http://nginx.net/" rel="noreferrer">nginx</a> can handle large amounts of traffic in much less memory than <a href="http://www.apache.org/" rel="noreferrer">Apache</a>, if you can sacrifice Apache's power and flexibility (or if you just don't need those things, which often, you don't).</li> <li>Remember that hardware is surprisingly cheap these days, so be sure to cost out the effort to optimize a large block of code versus "let's buy a monster server." </li> <li>Consider adding the "MySQL" and "scaling" tags to this question</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload