Enable PHP Opcache
I was profiling one of my services the other day and found that it was spending a noticeable amount of time just including files through require statements.
I was able to eliminate almost all of this time by enabling the OPcache, resulting in a noticeable performance boost.
I can't imagine a scenario where it is not worth using the OPcache in production, but you probably don't want it enabled in dev unless you turn the validate_timestamps
down to something like 1 so that your updates keep going through.
Below are the commands that you would need to run in Ubuntu 16.04 to enable the OPcache for the CLI.
References
- Last Place On The Net - How To: Enable PHP 7 OPcache on Ubuntu 16.04
- PHP Manual - OPcache
- SitePoint - understanding Opcache
- DigitalOcean - Does OPcode caching on by default in PHP 7?
First published: 16th August 2018