• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question Is there a way to restart reset Opcache periodically or invalidate not accessed files (dedicated FPM- handler)

serverman

New Pleskian
I'm currently using Plesk for a shared hosting server with the dedicated PHP-FPM handler per site.
This allows every site to have it's own Opcache, but this is also the issue...
Let's say there are 10 sites with 64 MB for Opcache, that's 640 MB in total!
Lot's of those sites don't get visited regularly, so the cache could be cleared after a while.

A solution could be to restart the PHP-FPM process for every site, but this will result in errors for visitors.
Another solution would be 1 PHP-FPM handler, but the cache will get filled by the big sites. This results in automatic Opcache restarts because the memory is full.

My question: is there a way to reset the cache periodically, or is there a way to clear the files from the cache when they haven't been access for let's say a week?
 
Hello, serverman

> A solution could be to restart the PHP-FPM process for every site, but this will result in errors for visitors.
You can just replace `restart` with `reload` to flush cache and avoid errors for visitors.
 
Thank you for your answer, this helps a lot.
How can I reload it though?

I find these services:
plesk-php73-fpm_DOMAIN_COM_144.service
plesk-php73-fpm_DOMAIN_COM_144

But whatever I try, I can't seem to find a way to reload it.
Using the service command it simply says unknown service.

They are definitely there in /lib/systemd/system:
-rw-r--r-- 1 root root 262 Jan 31 13:40 plesk-php73-fpm_DOMAIN.COM_144.service
drwxr-xr-x 2 root root 4.0K Jan 31 10:18 plesk-php73-fpm_DOMAIN.COM_144.service.d
drwxr-xr-x 2 root root 4.0K Jan 31 10:17 plesk-php80-fpm_DOMAIN.COM_144.service.d

This is what's in the service file, seems that it does not do a graceful reload?

ExecStart=/opt/plesk/php/7.3/sbin/php-fpm -c /var/www/vhosts/system/DOMAIN.COM/etc/php.ini --fpm-config /var/www/vhosts/system/DOMAIN.COM/etc/php-fpm.conf --nodaemonize
ExecReload=/bin/kill -USR2 $MAINPID
 
Or you could just run a php script containing opcache_reset();as a cronjob.

Thanks for your reply.
This would indeed work, except the problem is that every site has it's own PHP-handler.
I would have to make a cronjob for every website, for every client.
 
Why is that a problem anyway? Are you that low on resources?
Normally the kernel should swap out pages that have not been used for a long time when memory is needed.
 
Why is that a problem anyway? Are you that low on resources?
Normally the kernel should swap out pages that have not been used for a long time when memory is needed.
There are more than 50 websites hosted on the system.
In a worst-case scenario this could lead to a memory usage of 3.2 GB for Opcache alone.
If I can prevent old not accessed files to be cleared from the cache (let's say after a week), it would be much more efficient on the resources.

Normally the kernel should swap out pages that have not been used for a long time when memory is needed.
Swap usage went up by 2 GB by simply switching to dedicated FPM handlers, so it could already be doing that indeed.
 
Back
Top