OPCache causing PHP-FPM to crash after a few hours

This is related to other post i made about this issue.

I discover that opcache is the responsable for those errors. When its disabled all is working fine. But when its enabled the fpm pools start giving 502 errors. And the PHP logs is full of this:

[08-Aug-2022 13:26:09] WARNING: [pool mavequipamiento.com.ar] child 894470 exited with code 70 after 9784.181492 seconds from start

Do you know if there is something i can do to fix opcache. I really wish to have it activated, because it helps a lot with sites speed.

The server is a big one. With almost 600 sites. But it has a lot of RAM (256 GB), so i think thats not a problem.

I dont know what else to change in order to make this work. I played a lot with opcachen settings but its always the same.

There seems to be an bug with php opcache where you can “exit” maybe in combination with the max request settings?

1 Like


Thanks eris, you say its convenient to set max request to a low number?
Maybe some of the sites has errors that are causing the processes not to finish properly and after the pool is saturated its start to give 502 errors.

Wat is your exact pool configuration?

By default it is:


First i tryed with:

pm = dynamic
pm.max_children = 12
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 3
pm.max_requests = 4000
pm.process_idle_timeout = 10s
pm.status_path = /status

Then also with:

pm = ondemand
pm.max_children = 12
pm.max_requests = 4000
pm.process_idle_timeout = 10s
pm.status_path = /status

Both cases had the same issue with opcache.

Its important to clarify that the server has 500 sites.
But also has 256GB of RAM, and the used memory is never more than 60%.

I don’t have a server with more then xx sites so I have no experience with it.

Thanks anyways. That link its a clue. Will do some test. I think i already identify the problematic website. What surprise me is that one site makes all the php master processes across versions to fail.

That’s a lot of sites that I’m guessing you’re not the necessary administrator of each one so you probably don’t have quality control. I would probably set your maximum request for PHP much lower let it recycle the workers more. There’s also an option under /etc/phpxx/ phpfpm.ini cause PHP to restart if the workers get stuck.

Do you happen to be using (I forget the exact setting) but it’s commented in the php.ini to set of root for opcache scripts? You could be having sites somebody edited a core file and when it runs that version saved for other site cause a crash. So it might be better to set it so basically every site is caching scripts separate.

Also could be people making changes and opcache not updating timely. Do you have a revalidation period set? It kind of removes some of the benefits but you can set it much higher than the default like 5 10 15 minutes.

That’s all I can think of