Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>No two sites are alike. You really need to get a tool like <a href="http://jakarta.apache.org/jmeter/" rel="noreferrer">jmeter</a> and benchmark to see where your problem points will be. You can spend a lot of time guessing and improving, but you won't see real results until you measure and compare your changes. </p> <p>For example, for many years, the MySQL query cache was the solution to all of our performance problems. If your site was slow, MySQL experts suggested turning the query cache on. It turns out that if you have a high write load, the cache is actually crippling. If you turned it on without testing, you'd never know.</p> <p>And don't forget that you are never done scaling. A site that handles 10req/s will need changes to support 1000req/s. And if you're lucking enough to need to support 10,000req/s, your architecture will probably look completely different as well.</p> <h1>Databases</h1> <ul> <li>Don't use MySQLi -- <a href="http://ca.php.net/pdo" rel="noreferrer">PDO</a> is the 'modern' OO database access layer. The most important feature to use is placeholders in your queries. It's smart enough to use server side prepares and other optimizations for you as well.</li> <li>You probably don't want to break your database up at this point. If you do find that one database isn't cutting, there are several techniques to scale up, depending on your app. Replicating to additional servers typically works well if you have more reads than writes. Sharding is a technique to split your data over many machines.</li> </ul> <h1>Caching</h1> <ul> <li>You probably don't want to cache in your database. The database is typically your bottleneck, so adding more IO's to it is typically a bad thing. There are several PHP caches out there that accomplish similar things like <a href="http://ca.php.net/apc" rel="noreferrer">APC</a> and Zend. </li> <li>Measure your system with caching on and off. I bet your cache is heavier than serving the pages straight. </li> <li>If it takes a long time to build your comments and article data from the db, integrate <a href="http://www.danga.com/memcached/" rel="noreferrer">memcache</a> into your system. You can cache the query results and store them in a memcached instance. It's important to remember that retrieving the data from memcache must be faster than assembling it from the database to see any benefit.</li> <li>If your articles aren't dynamic, or you have simple dynamic changes after it's generated, consider writing out html or php to the disk. You could have an index.php page that looks on disk for the article, if it's there, it streams it to the client. If it isn't, it generates the article, writes it to the disk and sends it to the client. Deleting files from the disk would cause pages to be re-written. If a comment is added to an article, delete the cached copy -- it would be regenerated.</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