Low Opcache Interned Strings Storage

PHP’s OPcache can cache so-called interned PHP strings in shared memory so that the memory is allocated only once for these strings across all scripts. This reduces the memory overhead of every request.

Interned strings are, for example, literal strings inside your scripts like "Hello World" in this example:

<?php
echo "Hello World";

There is other data represented as interned strings inside the PHP engine, such as class names, file names, property names and many other things.

This cache should never be maxed out, because it’s an easy performance and memory win for every application. That is why it’s important to monitor that the default of 8 MB for opcache.interned_strings_buffer is large enough.

Increase this setting to a higher value if it runs low. By default, it’s 8 MB and there is no harm in quadrupling the value:

opcache.interned_strings_buffer=32

When raising the value higher take note of the fact that opcache.interned_strings_buffer shares its space with other OPcache data. So you might want to raise opcache.memory_consumption by the same value.

For example:

# 64 MB for interned_strings
opcache.interned_strings_buffer=64

# The default 128 MB for OPcache + 64 for interned strings
opcache.memory_consumption=192

When opcache.memory_consumption is not adjusted you might encounter the following error:

Fatal Error Insufficient shared memory for interned strings buffer! (tried to allocate …​ bytes)

When using Tideways' Observation feature, you’ll be advised on both of these values to ensure you have allocated enough memory to ensure your PHP application runs as fast as possible.

References:

Still need help? Email [email protected]