Open boppy opened 5 months ago
Additional findings:
https://github.com/krakjoe/apcu/blob/1ba5a2dade72d44ded54ebcb56b5392e2960c436/apc_cache.c#L755-L768
If the smart
-Flag is not set (since it's not mentioned on the config page, I never set it to begin with - see https://github.com/krakjoe/apcu/issues/504), the code checks if available is HALF the full cache size, and purges if not. - Since I'm not that deep into the code, I assume I miss something here, because as it's a switched thing, there for sure is some sense I'm just not getting ;)
Update I: ~2 days later:
After setting the smart
flag to 1
, the purge does not happen anymore. but after reaching approx. 75% of usage, the FPM processes do not respond anymore. I assume it's because APC cannot find a big enough slot to store needed information. I do not see any hint on that in the log files, just a "max_children reached", because it piles up.
Update II: ~3 days later:
The problem seems to boil down to the massive fragmentation my implementation caused. After resetting smart
to 0
again and upping the segment size to 3000M, I'm not running into purges or crashes anymore, because we still have a bunch of storage free at the end of the segment. I'm currently at > 54% usage without purge with 98% fragmentation. After another update that will run this night, the fragmentation should lower further, because I'm not inserting data multiple times per sec anymore.
Nevertheless I think that at least the hard crashes are something to look after. Also the docs could state, how and why the purge takes place.
Facts first:
5.1.23
8.2.18
(inside a docker container based onphp:8.2-fpm
)mmap
I observe that the cache expunges way too often without any hint why it's doing so.
Does anyone have an idea what's going on and how I can mitigate?
I implemented logging by calling the following script every 30s and writing its results to a log file:
I then analyze the output with:
My output is:
So basically it's always crashing if available space reaches 1000M.
I don't get why it's doing so. You see that my "Slots Hint" is
160k
(shown as 163.841 in col 2 "Slots"), while "only" handling around 100-130k entries (col 6 "Entries"). I thought the problem was that I only assigned 1000M to apcu at first. So I upped it to 2000M, but the expunges still happen often.Any hints are highly appreciated!
Full Config
``` [APCu] apc.enabled = 1 apc.enable_cli = 1 apc.shm_size = 2000M apc.shm_segments = 1 apc.shm_strings_buffer = 64M apc.gc_ttl = 30 apc.entries_hint = 160000 ```