Over a million developers have joined DZone.

WordPress Performance: Modernizing PHP and Opcode Cache

Emily Miller interviews Scott Walkinshaw as he gives advice for web teams on updating PHP and talks about the benefits of using an Opcode Cache.

· Performance Zone

Download Forrester’s “Vendor Landscape, Application Performance Management” report that examines the evolving role of APM as a key driver of customer satisfaction and business success, brought to you in partnership with BMC.

Website performance isn’t inherent—it requires a good grasp on best practices and a willingness to invest time and resources to achieve optimal results. Fortunately for the WordPress community, performance has been a hot topic as of late, and many are beginning to discuss and document what it takes to run WordPress at scale.

There are known, widely-accepted best practices for successfully running high-traffic WordPress implementations, one of which is running modern PHP with an Opcode Cache. We caught up with Scott Walkinshaw of Roots for some expert insight into modernizing PHP and the importance of using an Opcode Cache:

What Advice Would You Give Web Teams on Updating PHP?

Scott: Test. Test. Test. Updating the programming language your application runs on is a big deal. That being said, PHP makes this as straight-forward as possible. There are guides to backwards incompatible changes for every major version upgrade:

5.2.x > 5.3.x5.3.x > 5.4.x | 5.4.x > 5.5.x5.5.x > 5.6.x 5.6.x -> 7.0.x

Thankfully, PHP does a good job reducing the number of breaking changes. The majority of code should work seamlessly on most versions. The biggest changes were probably on 5.3 and 5.4.

WordPress is compatible out of the box from PHP 5.2 to PHP 7.0 as long as you're on a newer version (4.4+). It's WordPress' job to worry about their own core code compatibility. As a web team running a WordPress application, it's your responsibility to ensure all of your own custom code and all 3rd party plugins and themes work as well.

The best way to do this is to upgrade your PHP version on developer machines and staging servers first to test. Never just upgrade PHP on your production servers and assume it will work. Hopefully, you have a test suite you can run to detect regressions. Another good strategy is to have an error monitoring service so you can find new errors and compare error rates between PHP versions.

Just How Bad Is Running Outdated PHP for Performance?

Scott: Most developers know that programming languages add features and fix bugs in new versions. But most languages get faster and improve performance over time as well. PHP 5.2 was released in 2006. In the 9 years between 5.2 and 7.0, PHP has gotten much, much faster. Using an older version (such as 5.2) is like choosing to stick with an original iPhone instead of the latest 6S. Many PHP 7.0 benchmarks have shown up to 2x performance improvements for WordPress sites.

What Are the Benefits of Using an Opcode Cache?

Scott: Opcode cache simply saves PHP from doing a lot of work making your sites faster. Take WordPress for example: on a single request PHP is loading, parsing, and compiling thousands of scripts (files) into bytecode. Without any opcode caching, this happens on every request which is very inefficient.

With Opcode caching (like the now built-in OPcache in 5.5+), PHP stores this compiled bytecode. That means on subsequent page requests, PHP can skip a lot of work leading to huge performance gains.

See Forrester’s Report, “Vendor Landscape, Application Performance Management” to identify the right vendor to help IT deliver better service at a lower cost, brought to you in partnership with BMC.

performance,word press,php,opcode caching

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}