Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent Apache hangs when PHP APC cache completely fills up?

When APC cache is full, it hangs Apache. Apache responds to requests, however waits forever for APC cache to free some resources, but this will never happen.

I run every 10 minutes CRON job with my own small expunge script, which deletes expired entries from APC. Ok, I could add more memory to APC and/or I could run the expunge script more often. But that's not real solution, I am looking for some new way how to deal with issue.

like image 378
Frodik Avatar asked Nov 05 '22 02:11

Frodik


2 Answers

I find that setting a ttl changes APC's behavior when cache is full. By default, if the ttl is 0, APC has to empty the cache when it gets full. From the manual:

In the event of a cache running out of available memory,the cache will be completely expunged if ttl is equal to 0. Otherwise, if the ttl is greater than 0, APC will attempt to remove expired entries.

like image 138
Yacine Filali Avatar answered Nov 09 '22 11:11

Yacine Filali


It's not really the final solution, but I have written small PHP APC expunge script that I had proposed in my question. This script is run by CRON every 10 minutes and it manually removes expired items. It's far not perfect solution, but at least it helps a lot.

I am though still looking for final solution.

like image 34
Frodik Avatar answered Nov 09 '22 11:11

Frodik