0

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.

Hamid Alaei
  • 406
  • 4
  • 16
  • 1
    You 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 Jun 12 '16 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 Jun 15 '16 at 11:51
  • CLI wont benefit from OpCache as it always throws it away at the end of the script anyway. – Schodemeiss Jul 08 '16 at 11:28
  • 1
    FYI, it's now possible to use opcache for CLI. The cache can be written to disk. https://stackoverflow.com/questions/25044817/zend-opcache-opcache-enable-cli-1-or-0-what-does-it-do/35880017#35880017 – Mark Thomson Sep 28 '18 at 16:16

1 Answers1

2

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.

Phil
  • 2,008
  • 1
  • 17
  • 23
  • 1
    The stuff on kinsta.com is not correct! I already check with my framework and Wordpress ! https://www.youtube.com/watch?v=cN-PqerQ9DI –  Mar 12 '19 at 13:21