Results 1 to 7 of 7

Thread: Optimal Opcache settings?

  1. #1
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    227

    Optimal Opcache settings?

    We use Opcache for PHP caching. Since PHP continuously improves we are looking what the optimal Opcache settings could be. This is mainly regarding the following settings:

    opcache.memory_consumption=3072
    opcache.interned_strings_buffer=32
    opcache.max_accelerated_files=40000

    After tests it seems that setting the interned_strings_buffer too high this leads to a worse performance but not on every server. We are curious: what settings are you using for these 3 values? Ofcourse this will depend on how many websites and the specs of the server. Lets say the server has +/- 200 users/300 websites and 12 GB of memory. Please let me know what settings you are using, how many users/websites and what the specifications of the server are.

  2. #2
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    13,750
    Looking for Optimal opcache settings and trying someone's else setup is not what you would really like, believe me.

    The option opcache.max_accelerated_files does not depend on a number of sites and a number of users. A single site written with the help of a Zend framework might have much more PHP scripts than 10 simple WP sites. So you should not count on these numbers, but use find /home/ -name \*.php to see how many files you have there.

    As for
    opcache.memory_consumption you will need to monitor closely number of hits and misses together with an amount of used memory. You don't want to waste memory, but opcache should have enough RAM for caching most used PHP scripts.
    Regards, Alex G.

    - Get the best commercial DirectAdmin support and hire me on poralix.com
    - Follow and like @Poralix on Facebook

  3. #3
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    227
    Hi Alex, thank you for your answer. The main reason of my question is that most tutorials advice to use lets say 256 MB or 512 MB for memory_consumption. We already use 3 GB. This can mean 2 things:
    - We have to conclude that we missed the good point and 3 GB is way to much (same goes for our other settings).
    - These tutorials are not written for larger usage.

    Therefore i was interested in other hosters their config, just to compare. Not to take it as a new truth

    I can imagine that assigning too much memory or using a too high accelerated files number at some point will hurt performance instead of deliver performance. For example at the point that looking at the accelerated_files index is taking more time than simply calculating the PHP code. About the accelerated files: i checked 1 server and it has 0.5 million php files in /home. I am not sure if that is the amount we want to set in the accelerated files.

  4. #4
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    13,750
    Give this a try https://github.com/amnuts/opcache-gui/ and see how good your opcache works. I did not compare time to search cache VS time to process PHP, so I don't have anything to comment here. Probably someone else has more details on it.

    We use:

    Code:
    opcache.memory_consumption=512
    opcache.max_accelerated_files=16000
    for default installations as a starting point.

    At least one of the recently maintained by me server has 4Gb limit in opcache with 2.5Gb of average usage (with 32Gb of total RAM).
    Regards, Alex G.

    - Get the best commercial DirectAdmin support and hire me on poralix.com
    - Follow and like @Poralix on Facebook

  5. #5
    Join Date
    Jul 2019
    Posts
    87
    Always have questions about optimization, php, MySQL, apache and Nginx, is there any tutorial?

  6. #6
    Join Date
    Apr 2009
    Posts
    2,421
    To enable opcache in custombuild, please see https://help.directadmin.com/item.php?id=567 - also here is a very good article worth reading: https://tideways.com/profiler/blog/f...ching-suprises - and also https://ma.ttias.be/mitigating-phps-...ensitive-data/

  7. #7
    Join Date
    May 2008
    Location
    Bulgaria
    Posts
    970
    The optimal settings for opcache on PHP-FPM with shared hosting (many sites) is... disabled This is personal opinion due to personal experience of course.

    My reasons:

    1. I did not notice any difference in overall load. My bottleneck is the disk usage and it did not decrease. No speed difference in some heavy websites loading time too.
    2. Each php-fpm process becomes huge because of the cache each process must carry on

    So what happens is that I wasted lots of ram for no benefit.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •