performance

MySQL performance tips from around the web

Gospel: use InnoDB, never MyISAM It seems everybody on StackExchange is singing from the same gospel: “[How can I] prevent queries from waiting for table level lock?” Answer: use InnoDB. The major advantages of InnoDB over MyISAM. “Even in a read-intesive system, just one DELETE or UPDATE statement will quickly nullify whatever benefits MyISAM has.” […] » about 400 words

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

Site Load Performance Benchmarks

The Loop’s Jim Dalrymple compiled the following numbers for the time it takes various tech sites to load in a browser in late 2011:

  • The Loop: 38 requests; 38.66KB; 1.89 secs
  • Daring Fireball: 23 requests; 49.82KB; 566 milliseconds
  • Macworld: 130 requests; 338.32KB; 8.54 secs
  • Ars Technica: 120 requests; 185.99KB; 2.08 secs
  • Apple: 46 requests; 419KB; 1.39 secs
  • CNN: 196 requests; 269.41KB; 4 secs
  • BGR: 368 requests; 2.74MB; 35.33 secs
  • AppleInsider: 141 requests; 649.39KB; 5.64 secs
  • Facebook: 137 requests; 993.54KB; 11.19 secs
  • MacStories: 119 requests; 2.16MB; 2.13 secs

John Gruber started this by calling out The Next Web for it’s slow performance:

  • TheNextWeb: 342 requests; 6MB; no time info

More benchmarks can be seen at Browsermob.

WordPress comments_template() and wp_list_comments() Performance

This thread on memory usage while executing WordPress’s comments_template() raised my awareness of performance issues related to displaying comments on posts in WordPress. The first thing to know is that all the comments on a given post are loaded into memory, even if the comments are paged and only a subset will be displayed. Then comments_template() calls update_comment_cache(), […] » about 500 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

Why PHP’s RegEx Is Slow, And What You Can Do About It (if you happen to be a committer on the PHP project)

Regular Expression Matching Can Be Simple And Fast, by Russ Cox:

Perl [and PHP and others] could not now remove backreference support, of course, but they could employ much faster algorithms when presented with regular expressions that don’t have backreferences.

How much faster? About a million times (no, I do not exaggerate).

I use a lot of regular expressions, and relatively few of them use backreferences. It’d be worth optimizing.

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.

Looking Back At Mac Hardware Performance

I recently replaced the Mac Mini I use to host my web development with a PowerMac G4. (Story: the Mini was mine, a personal purchase I made to support my work on Scriblio and other WordPress-related projects, but recent changes in our network and firewall policy made the machine inaccessible from off-campus without using the […] » about 200 words

Scaling PHP

This two year old post about Rasmus Lerdorf’s PHP scaling tips (slides) is interesting in the context of what we’ve learned since then. APC now seems common, and it’s supposedly built-in to PHP6. Still, I’d be interested in seeing an update. Are MySQL prepared statements still slow?

And that’s where Rasmus’ latest presentation comes in. We don’t learn anything about MySQL prepared statements, but we do learn how to find choke points in our applications using callgrind and other tools. In his examples, he can do a little over 600 transactions per second with both static HTML and simple PHP, but various frameworks — with many inclusions and function calls — can slow that to under 50 transactions per second (I suppose they’d explain that in a TPS report).

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

More Web Performance Tips From Steve Souders

Hearing Steve Souders at WordCamp last week got me thinking about website performance, so I went looking for more. The slides from his WordCamp talk are online, but he gave a similar talk at Google I/O which got videotaped and posted richer detail than his slides alone will ever reveal.

Also on his blog: Use the Google AJAX Libraries API when you don’t have a CDN, and a post that asks why make users wait to download all your javascript before they see the page if you’re only going to use 25% of it at first?

Quercus PHP To Java Compiler vs. WordPress

Emil Ong is the Chief Evangelist and a lead developer for Caucho Technology, the developers of the Quercus PHP to Java compiler. The idea, I guess, is to write in PHP, deploy in Java, which some people say is better supported by the “enterprise.”

Ong claims 26% performance improvement over Apache + mod_php + APC. That sounds great, I suppose, but it’s less than what Chris Lea suggests is possible if you simply replace Apache with Nginx.

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.

Changes To WordPress Object Caching In 2.5

Jacob Santos‘ FuncDoc notes: The WordPress Object Cache changed in WordPress 2.5 and removed a lot of file support from the code. This means that the Object Cache in WordPress 2.5 is completely dependent on memory and will not be saved to disk for retrieval later. The constant WP_CACHE also changed its meaning. I’ve just […] » about 200 words