Understanding OpCache

PHP in version 5.5 comes with a caching engine built-in – OpCache – which stores precompiled script bytecode in the memory. If you’re familiar with APC or Xcache, you will already know how such engines work. As each PHP script is being compiled at runtime, a part of the execution time gets used for transforming the human readable code into code that can be understood by the machine. A bytecode cache engine like OpCache, APC or Xcache does it only once – during the first execution of a specific PHP file. Then the precompiled script is being stored in memory, which should lead to performance boosts in your PHP applications.

Over the web you will easily find a lot of tutorials covering all the OpCache installation and configuration steps (it is enabled by default on 5.5, but can be installed as an extension on older versions). Read the article below to find the answers to some of the typical questions regarding different practical aspects of working with this particular cache engine.

Of course, it depends. If your server manages to handle the incoming traffic and keep low response times, you probably won’t feel the need to work on performance. But on a bigger website with a lot of traffic each little optimization step may count. Implementing OpCache may allow you to handle more requests per second and return the response quicker than without a bytecode caching engine. As OpCache is quite easy to install and configure, you won’t spend too much time on setting everything up.

If you’re looking for some OpCache performance tests, you should certainly read the AppDynamics article on implementing this cache engine. In their tests the installation of OpCache reduced the mean response time of a website by 14%. The reduction of response times of different actions of a web application varied from 6% to as much as 74%. As explained in the article, different code parts may benefit more or less from implementing a bytecode caching engine. I encourage you to read the article in detail and check where you can get the highest performance boost.

If you’re looking for some other resources regarding the OpCache performance, check the examples on fideloper.com and massivescale.com. Both tests reported about 50% decrease in response time after installing OpCache …

 

Vous aimerez aussi...

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *