Should I enable OpCache in production? Any benchmark for php 7.0? Is there any benchmark that tells how much a Laravel application on a PHP 7.0 server can benefit from enabling and tuning opcache? It would also be nice to share your experience.
- 1You should definitely enable opcache. I remember that WordPress has something like 8x smaller response time with opcache. Difference may be less pronounced for Laravel, but will still be huge.NikiC– NikiC2016-06-12 20:13:17 +00:00Commented Jun 12, 2016 at 20:13
- I mistakingly thought it was disabled! But it is not for web. I also enabled it for cli for laravel jobs and crones. Is that OK too?Hamid Alaei– Hamid Alaei2016-06-15 11:51:39 +00:00Commented Jun 15, 2016 at 11:51
- CLI wont benefit from OpCache as it always throws it away at the end of the script anyway.Schodemeiss– Schodemeiss2016-07-08 11:28:05 +00:00Commented Jul 8, 2016 at 11:28
- 1FYI, it's now possible to use opcache for CLI. The cache can be written to disk. stackoverflow.com/questions/25044817/…Mark Thomson– Mark Thomson2018-09-28 16:16:41 +00:00Commented Sep 28, 2018 at 16:16
1 Answer
I have opcache enabled in production and have had no problems. There is undoubtedly a performance improvement so I would recommend enabling it.
I'm not a Laravel developer, however there's a bunch of performance comparisons out there. For example, a quick Google search reveals https://kinsta.com/blog/the-definitive-php-7-final-version-hhvm-benchmark/ which has a Laravel (with and without opcache) benchmark as well as Laravel based products (OctoberCMS, PyroCMS, Flarum).
While there's no definitive benchmark, it's worth looking at https://www.techempower.com/benchmarks/#section=data-r12&hw=peak&test=fortune&l=13yebk for PHP framework benchmarks. opcache is not specifically tested, but HHVM is which should give you a rough idea of performance improvement.