Today’s post covers the joys and benefits of opcode caching. If you have a very active site, this caching method can provide a great deal of relief to your servers by significantly reducing load averages and CPU utilization.
How does it work?
It’s quite simple, actually. Without caching configured, each time a PHP-based page is requested by a user, the server gathers all of the needed files and “compiles” them into a result which it can understand and deliver. This result is known as “opcode”.
The technique of opcode caching preserves this generated code into a cache so compilation only needs to happen once and then can be used over and over again for numerous requests by numerous users.
Several PHP caching choices exist including APC, Zend, and XCache. I’ve chosen eAccelerator based on numerous reports such as this one which show its distinct performance advantage and also in large part due to the personal recommendation of seasoned server architects such as RackerHacker.