PHPNG – It’s pretty quick.

I spent a few days in December tweaking a number of speed-related items on the websites.

Towards the end, I decided to take a look at the changelog for PHP and discovered that “PHPNG” has been in the works for quite some time. The performance improvements mentioned on were nothing short of impressive, so I figured it was worth testing out to see if I’d see similar results.

I fired up a VM with Ubuntu 14.04.1 LTS, installed Nginx, MySQL, and threw in a WordPress install. Because a blank WordPress install isn’t really representative of an actual use-case, I installed WordPress’s Theme Unit Test, and a few plugins. For those who haven’t heard of the Theme Unit Test, it’s essentially a full, fake “test blog” that imports a pile of fake users, pages, and posts, designed to help theme developers test their themes.

Now I had something that resembled a real blog.

I ran the site through Apache Bench, first using PHP 5.5.9 (the version that’s currently pulled with an apt-get via Ubuntu 14.04), and then again using the pre-packaged PHPNG binary provided by Zend (PHP 5.7.0 – built on Aug 7 2014). You can find simple instructions for installing PHPNG on Zeev’s blog.

The Apache Bench settings were pretty straightforward:

ab -n 10000 -c 100

This was a fairly simple back-to-back test. I was just looking for a general idea and the environment’s pretty controlled anyway, so I didn’t feel the need to get multiple data points. Here are the before and after results:


Essentially, PHPNG was about 1.9x as fast. Watching “top” (not shown in the screenshots), it also used a little less memory (roughly 90%).

It’s worth mentioning a few things here just to be clear on the set-up:

  • This was done on a local VM, i5 Sandy Bridge (~3.3Ghz IIRC). The VM had 1 core assigned to it and was given 512MB of RAM. The host machine was idle.
  • No caching plugins were installed.
  • Nginx was just a default install. No fastcgi cache, no tweaks, etc.
  • There weren’t any tweaks to MySQL – just a default install.
  • There weren’t any tweaks to the default PHP settings. Default installs.
  • …in other words, not exactly an average use case. At least, I hope not.

Bugs & Issues

Keeping in mind that it’s a development version and that this build was from back in August (I wasn’t keen on building the latest from source), here were some of the issues I ran into:

  1. The WordPress Menu Structure is broken. Create or modify any menu with items in it, and as soon as you hit “Save Menu”, the order of any custom menus is randomized. It’s not actually *completely* random – if you sort it the way you’d like it and then hit save multiple times, eventually the “random” order will line up to where you wanted it. Whether it’s an issue with PHPNG or simply WordPress doing something unsupported by it, I’m not sure.
  2. phpMyAdmin seems to be incompatible. Essentially, it’s uninstalled when you install the PHPNG binary provided by Zend, and can’t be re-installed (not easily, anyway). You’ll get a message mentioning that you’re using an unstable distribution and that php5-json is required but is not going to be installed.
  3. WP Super Cache seems to be incompatible. I got a blank screen when trying to configure it. Trying it on a live site, the whole site got a blank screen. W3TC and Hyper Cache both seem to work fine, however.

Really, nothing that can’t be worked around as far as WordPress goes. For all I know, they may be fixed in the latest version of PHPNG anyway.

Closing Thoughts

A version of PHP that runs almost twice as fast is a great thing to see. I tend to see PHP as one of those things I try to avoid where possible by caching aggressively. That said, it’s good to know that the times it can’t be avoided, it’ll at least run much faster than it did before.