Want to have APC with PHP 5.5?

I was upgrading PHP on my production server the other day. I hopped over to the official www.php.net site and saw that the latest release out was PHP 5.5.1. Like any good dev practice, the first thing I did was look around the forums to see if there were any open bugs that might break my app.

I did notice one quick thing: the original JSON extension by Douglas Crockford got replaced by pecl-json-c due to some licensing drama. Honestly, as long as JSON encoding still works under the hood, I don’t really care and it works totally fine (You can read more about it on http://philsturgeon.co.uk/blog/2013/08/fud-cracker-php-55-never-lost-json-support)..

But then I hit a much bigger roadblock: APC just wouldn’t work.

I tried over and over to compile different versions of APC with PHP 5.5.1, but I had absolutely no luck. I saw people talking on forums saying that APC is basically dead for newer PHP versions and that everyone should switch to Zend Optimizer+ (which is now built into PHP as Opcache).

Hold on a second… I think a lot of people are getting confused here. If you were using APC purely for opcaching (bytecode caching), then yes, Zend Optimizer+ is the direct replacement. But what if you were using APC for user caching (storing data variables in memory)? The forum answers just said, “Oh, just use Memcached or Redis.”

I wasn’t really sold on those options for this specific setup. I didn’t want the overhead of setting up a whole new Redis/Memcached daemon just for basic local user caching. I even found a development branch on the official APC GitHub repo that did compile, but since it’s unstable and still in active development, there was no way I was risking it on a production server.


That’s when I found APCu (specifically version 4.0.1). It is a direct fork of APC, but stripped down to handle only user caching. It completely drops the old opcache part, which makes it perfect if you pair it with PHP 5.5’s built-in Zend Optimizer+.

It compiled smoothly, worked flawlessly, and it’s running right now on my production server. Huge thanks to Joe Watkins for putting this together!

Since APCu only handles user data, I paired it with Zend Optimizer+ for the bytecode caching. Before pushing everything live, I ran some benchmarks using http-perf to see if the combo actually held up. The difference with Zend Optimizer+ turned on was night and day—the performance bump was huge.

It’s been serving production traffic for a bit now, and everything is running incredibly smoothly. If anything breaks or acts up down the road, I’ll be sure to update this post.

How are you guys handling the transition to PHP 5.5? Are you moving to APCu, or did you switch completely to Redis? Let me know in the comments!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.