Optimization

Testing apply_filters() times

Testing how long it takes to assign a variable versus assigning through WordPress’ apply_filters(). Filters are core to WordPress, but I haven’t yet looked at the total number of apply_filters() calls used throughout the code. The answer to this question is that calling a non-existing filter before assignment is about 21 times more costly than […] » about 300 words

Testing file include times for a file that may or may not exist

Question: Should you check for a file before attempting to include it, or just suppress errors? Calling file_exists requires stating it twice if the file does exist, so that could take longer. Answer: the file_exists pattern is more than five times faster than the @include pattern for a file that doesn’t exist, and not substantially […] » about 300 words

Speed WordPress MultiSite With X-Sendfile For Apache

Like WordPress MU before, MultiSite implementations of WordPress 3.0 use a script to handle image and other attachment downloads. That script checks permissions and maps the request path to the files path on disk, then reads the file out to the web server, which sends it to the browser. That approach has some inefficiencies, and […] » about 400 words

Systems Wrangling Session At WordCamp Developer Day

What is the current status of web servers…Is Apache 2.x “fast enough?”

Automattic uses Lightspeed (for PHP), nginx (for static content), and Apache (for media uploads). For WordPress-generated content, all server options are approximately the same speed.

What about APC?

Automattic uses beta versions of APC, and provides a 3-5x performance increase. It’s tied closely to the PHP version, so Automattic recently switched from PHP 4 to PHP 5.

Databases?

MySQL scales well and is easy enough to use that there’s little reason to consider other DBs for WordPress content. Other applications may have different needs. Note: FriendFeed uses MySQL to store schema-less data. Single-table key lookups in MySQL are faster than getting the data from Memcached.

Caching?

Automattic uses Batcache for full-page caching (.002 to .003 second), Memcached persistent object cache, very limited MySQL query cache (never larger than 256MB), sufficiently large key buffer.

HyperDB?

HyperDB solves DB scaling problems.

Backups

User-data backed up every hour, if something changed. Every blog backed up every 12 hours. Dedicated MySQL slaves do LVM snapshots for backups.

Amazon To Offer Content Delivery Services

Via an email from the Amazon Web Services group today: …we are excited to share some early details with you about a new offering we have under development here at AWS — a content delivery service. This new service will provide you a high performance method of distributing content to end users, giving your customers […] » about 400 words

Steve Souders On Website Performance

Steve Souders: 10% of the problem is server performance, 90% of problem is browser activity after the main html is downloaded. He wrote the book and developed YSlow, so he should know.

JavaScripts are downloaded serially and block other activity. Most JavaScript functions aren’t used at OnLoad. We could split the JS and only load essential functions up front, and load all the rest later. How much might that help? He says 25% to 50%. This quickly gets complex, but he’s got a simple plan that considers three questions:

  • Is the script URL on the same host as the main HTML?
  • Should the browser indicate it’s busy, or not?
  • Does script execution order mater?

And at that point things started to get too interesting to take publishable notes. I clearly need to pay more attention to this guy.

Stats he mentioned without being specific about the source:

  • Google: 200ms longer download time cut revenue by 20%
  • Yahoo: 100ms of latency costs … big.

Optimizing Inserts/Updates On MySQL Tables

When doing a bulk insert/update/change to a MySQL table you can temporarily disable index updates like this:

``` ALTER TABLE $tbl_name DISABLE KEYS ```

…do stuff…

``` ALTER TABLE $tbl_name ENABLE KEYS ```

From the docs:

ALTER TABLE ... DISABLE KEYS tells MySQL to stop updating non-unique indexes. ALTER TABLE ... ENABLE KEYS then should be used to re-create missing indexes. MySQL does this with a special algorithm that is much faster than inserting keys one by one, so disabling keys before performing bulk insert operations should give a considerable speedup. Using ALTER TABLE ... DISABLE KEYS requires the INDEX privilege in addition to the privileges mentioned earlier.

While the non-unique indexes are disabled, they are ignored for statements such as SELECT and EXPLAIN that otherwise would use them.