[00:03] be in the camp of 90% of people that do not check if their opcash uh configuration settings are sized for their application even though opcash is enabled since PHP 5.5 that does not mean [00:18] that it's configured correctly you can't just enable it and uh assume that everything is going to be all right take this customer for example they didn't uh this customer for example they didn't uh size up correctly and lost 20% in [00:33] performance because of this mistake when they corrected it compile times and autoloading times dropped significantly giving them a 20% Improvement in giving them a 20% Improvement in performance from 1.6 seconds to 1.3 [00:48] seconds in the 95% high that is really great for just setting a few values different configuration values differently what are the important UPC settings that you need to look into there are three settings that are the [01:04] most important ones to configure the first one is called opcash memory first one is called opcash memory consumption its default is 128 mbes then there is opcash Max accelerated files which is uh defaulting to 10,000 files [01:21] and third there's opcash intern strings buffer which defaults to 8 MB so what are the right values for these settings you can can check in PHP info output under the Zen opcache section you find a few statistics that give you a lot of [01:37] information that you can make the right decision on these settings for the opcache uh memory consumption setting you need to look at consumption setting you need to look at two configuration values used memory and [01:50] free memory when the free memory statistic is going towards zero then the used memory is going towards the let's say 128 megabytes and in that case it's an indicator that you need to increase the [02:04] the memory for modern PHP applications 128 could be too small it might be necessary to increase it to to increase it to 192 or 256 memory uh for example [02:23] Max accelerated files and the default of 10,000 is really too small for applications such as shopware laravel uh Symphony or magenta 2 the [02:35] reason for this is that they are using PHP files for caching and once uh a lot of these cache files are generated this means that uh files are generated this means that uh in addition to the um third party [02:50] libraries that are loaded through composer you quickly get to 10,000 files and then no additional files will be uh stored into opcache even though the memory consumption might potentially allow it this means that [03:06] only um a few scripts are compiled over and over again in every request causing let's say the 20% drop that you saw for this customer before to check if um you are next to this limit you need to look at the two [03:22] values cached keys and Max Keys why are they not called cached files and Max files files the reason for this is that uh opcash internally [03:34] translates the max accelerated files to the nearest prime number so for the default of 10,000 you get 16,2 29 keys and um these are filled [03:48] 16,2 29 keys and um these are filled with um uh with PHP files if the cached Keys value comes close to the max keys that means that you're at the maximum and should increase the value I don't see a problem by increasing this [04:03] uh configuration setting 10-fold it doesn't have any limitations to do that and the opcash memory consumption is already in Upper Bound for how much uh stuff is going to be stored in opcash the third setting that you need [04:18] to look at is the intern strings buffer intern strings are things like class intern strings are things like class names function names variable names and uh literal strings that are inside your PHP scripts all these can be shared uh [04:34] in memory and used across all the different parallel processes that run different parallel processes that run PHP for example in Apache or PHP fbm if you don't set this setting high enough then every request needs to [04:49] reallocate the same memory for a string that is used across different uh scripts and processes and that is uh very wasteful the default value of 8 megab is really too small for modern applications again [05:03] and you set should always set it to the highest possible value of 32 megabytes and then you usually don't run into problems [05:18] BS in your production setup sometimes it's not that easy to get at the PHP info output and you really need to look at it from the web uh server side because looking at the zent opcache statistics from the command line uh [05:34] accesses a different opcache and uh the values from there cannot be com um used the web server so there are a few tools [05:46] available that um allow you to extract this information um into a metrix tool you can build this yourself as promeets for example and uh gather this data in [05:58] any kind of metric store that you are already using or you can use uh a tool like tight ways who collects this information across all application servers Aggregates it and alerts on it [06:11] uh when for example opcash is running low in memory opcash is running low on cash keys or opcash is running low on intern strings memory you can also read up on this on our blog at tight.com which uh has all [06:26] our blog at tight.com which uh has all the information about um setting the correct values for opcache you can find the link by clicking here