-
Notifications
You must be signed in to change notification settings - Fork 665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adjust opcache settings #192
Comments
cc @MichaIng is this how it is supposed to work? |
Jep works as intended when the interned strings buffer usage raises over 90% of configured size. I'm actually wondering which app (?) is causing this since I'm running my instance with max 3.5 MiB interned string buffer used 🤔. |
@happyreacer which apps do you have installed? Please post the output of |
@MichaIng is there maybe a way to find out which files get cached in opcache? In this way we could probably better investigate which app is doing that... |
Generally OPcache stats can be obtained via:
This needs to be called from the same PHP parent process which runs Nextcloud to see the same cache (which is shared across all FPM children at least), so in CLI it is useless 😉. Change Neat is also the opcache-gui, simply download the index.php somewhere into your webroot and call it. Shows nice stats and gauges and searchable cached script lists. For the OPcache itself it is trivial, all PHP files are cached, you can list them, evict them etc. For the interned strings buffer it is however more complicated and I'm not away of a way to actually list the content of this buffer. Until today I failed to understand which kind of strings are actually stored, asked on PHP mailing lists already, and other unexpected behaviour remains unclear: https://stackoverflow.com/q/67853338/16145737 (which indicates that we should recommend the next power of two instead "higher than ".) However, literal strings, symbols, internal class and function names alone are not sufficient to explain the actual interned strings buffer usage, as long as a PHP application does not create and remove large temporary PHP scripts without evicting them from cache when not used anymore, or when eviction does not or cannot include the cached interned strings. |
Thanks for the deep insights! Do you think that adding the same change that was made in the NcVM will solve the issue here, too? |
It should. The other fixed OPcache settings which were recommended before by Nextcloud, could be btw removed (when currently set). They are all PHP defaults anyway, some make things worse than better. Together with the changed admin panel recommendations, I updated the Nextcloud docs according to the new recommendations and, aside of the usage based recommended cache size increments, other settings which can increase performance: https://docs.nextcloud.com/server/latest/admin_manual/installation/server_tuning.html#enable-php-opcache |
nice!
You mean those? all-in-one/Containers/nextcloud/Dockerfile Lines 89 to 94 in 3041e51
Okay, cool! Will have a look at them later...
Not that I am aware of... |
Yes exactly. These are all PHP defaults, some not even reasonable (10000 accelerated files is an invalid value which is increased automatically to 16229). Only |
Honestly I didn't know that we set them until I've looked it up 😅 |
It was until recently part of the server tuning docs to apply them like that, so this has been adopted by most Nextcloud appliances, I guess 🙂. |
|
Thanks! |
My list is much smaller:
I once tested to max out OPcache usage by installing, enabling and accessing literally all apps available on the store, skipping only those which are incompatible with each other or incompatible with the NC version, after overriding the compatibility warning. And I reached only around 64 MiB. But to be true, I haven't monitored the interned strings buffer that time and I'm also not sure whether app usage (feeding with content) has any effect on it. In theory it shouldn't as it is related to PHP scripts only, not database query content or the resulting HTML documents served, but not 100% sure. |
Oh I see you disabled files_sharing 😅 Yes I mean Nextcloud AIO is meant to include all in one so it is logically that much more apps are used and enabled here ;) Although I must say: that is really a loong list! |
Jep, fully legit, and I actually added the new checks to be able to reduce OPcache sizes, especially the overall one which for NC alone never needs to be above 64 MiB, thinking that it may reduce admin panel warnings, especially for users which do not have access to PHP settings, on shared hostings or such. Interesting that there are cases where the interned strings buffer is too low with 8 MiB. Causes questions/support/changes like this, probably annoying for the one or the other, on the other hand applying the change then may have the little performance benefit which those recommendation were intended for in the first place 🙂. |
to clarify - if someone is getting this warning, should we be proceeding with the tuning guide referenced, or are there other changes planned.. I have read through the ticket, but as I am no conversant in PHP, I am not confident of the path forward... |
Simply follow the recommendation given by the admin panel. What we may do is fine tuning the used vs available ratio (or using the absolute free/unused value instead of a ratio) at which the warning is shown, but that doesn't affect the generally reasonable recommendation to have at least 10% of the limits left as buffer. What we may also change is to not just say "higher than X" but recommend a concrete value, e.g. the next power of two for overall OPcache size and interned strings buffer, and the next valid prime number for max keys. |
Read through the tuning guide as well as the other tickets associated to this. I've got Nextcloud 23.0.2 running on a shared hosting, where my server admins pointed out I'm able to raise the 8MB: https://ibb.co/smNC6xL phpinfo.php also sees Requesting to clarify this further - what is the recommendation to act on this on shared hosting? |
Is it only a single Nextcloud instance served by this PHP pool? I assume that it's a dedicate PHP pool/instance per shared hosting user, otherwise this would be a security vulnerability. You can check it via custom PHP script or opcache-gui: #192 (comment) ... although on your phpinfo output I see 4096 MiB Also note that You can see this as well in your phpinfo since local value and master value both have changed. In case of a shared hosting with shared PHP pool/instance, this would mean that you change the value for all users of that shared hosting until server/PHP restart or until another user changes the value the same way, showing how bad that idea would be 😄. If this was really the case, you should ask your hosting provider to split PHP instance/pool per user. |
After several hours (about 10-12 hours) I have the following warning in the settings overview:
`The PHP OPcache module is not properly configured:
When I stop and restart the containers, the warning is gone.
The text was updated successfully, but these errors were encountered: