Nextcloud 23.02 OPcache interned strings buffer

Hey guys, this recommendation is not a bug but a new way how OPcache related recommendations are obtained since Nextcloud v23.0.1:

Previously a fixed set of settings was recommended, basically matching the PHP default values. Now the actual OPcache usage is obtained, and when one limit is reached by >90%, a recommendation is shown to increase that particular setting. That way the recommendations have become much more accurate, serving the actual intention.

E.g. Nextcloud uses ~32-64 MiB overall OPcache memory, based on used apps, but the recommendation was to apply 128 MiB, being wrong, not providing any performance benefit. Same with the maximum stored keys/scripts, where 10,000 was recommended while Nextcloud usually uses 3,000 - 4,000.

The default 8 MiB interned strings buffer applied by PHP (when not set differently) is usually sufficient as well, e.g. my Nextcloud instance uses 3.5 MiB, but this seems to highly depend on used apps. 16 MiB was observed to cover more cases, but obviously not all of them. I’m not sure whether some apps make much use of large strings, or even temporary scripts (PHP files) which are then not evicted properly, but generally, when the system’s RAM allows, it makes sense to follow the recommendation to maximise performance, since otherwise, when the buffer is full, new requests may need to first evict strings before new ones can be cached, and the evicted ones need to be cached again when requested later.

While this new behaviour allows to reduce OPcache limits to what Nextcloud actually uses, more importantly it better covers cases where Nextcloud is not the only web application served by the same webserver and PHP (OPcache) instance. E.g. I administrate another server where phpBB, Wordpress and Matomo run on. And it uses ~350 - 400 MiB overall OPcache and up to 150 MiB for internal strings, caused by indeed temporary large PHP scripts created, used and cached during website usage. The defaults (and previously recommended) 128/8 MiB would break the performance benefit provided by OPcache for these websites. An accurate recommendation can only be done based on actual usage.

Indeed, like all warnings on the admin panel, those are not mandatory to follow, but recommendations based on what Nextcloud is able to measure. Not following these won’t break your Nextcloud, OPcache is a pure performance buffer. There are other warnings you can safely ignore, like imagick PHP module, bcmath and gmp modules if you do not use WebAuthn based passwordless authentication anyway, the X-Download-Options header warning if none of your users access Nextcloud via Internet Explorer, and more.

Since more than 16 MiB are a bit unexpected to be ever used, if Nextcloud is the only web application served by your webserver/PHP instance, and the admin panel shows a recommendation to apply >16 MiB, it would be interesting to see your apps list. Probably we can find similarities or identify the app which allocates that much interned strings. Maybe there is indeed an issue with cache eviction in one of these apps, or it simply contains a large number of strings/text shown in its interfaces.

12 Likes