Php – What does apc.mmap_file_mask really do

alternative-php-cachePHPphp-fpmshared-hosting

I want to use APC in a shared environment, but the main problem is of course, opcode sharing.

To overcome this, I've thought about using different apc.mmap_file_mask for each user (they're chrooted through php-fpm), so the "file" created by APC would not be shared, but would be personal to the user.

Of course, I've noticed I'm wrong for serveral reasons… and the biggest one is about "What does really do apc.mmap_file_mask?": I've thought it was like a pointer to the memory region used by APC, but i'm not that sure about it.
And, of course, there is no file in the path I've used (/tmp/apc.XXXXXX): no file on the machine's /tmp, and no file in the chrooted environment's (/home/vhosts/0001/tmp).
So, what does really do apc.mmap_file_mask?

My actual configuration is:

apc.mmap_file_mask = /tmp/apc.XXXXXX
apc.num_files_hint = 2048
apc.max_file_size = 10M
apc.ttl = 7200

I've already checked what happens with phpinfo(), and it doesn't translate the value: it still gives me /tmp/apc.XXXXXX (but apc.php says the cache was hit and I have better timing values… thus it is working).

Best Answer

Have you tried APC.php on the active web server? if you are using SHM and not MMAP that could explain this. The filemask simply allows it to save the ap file with random digits as per your specification to a particular location. You can even send it to /dev/zero as per a blog post here http://www.nigeldunn.com/2011/05/02/unable-to-allocate-memory-pool/

Here is explanation of various memory/file locations https://stackoverflow.com/questions/904581/shmem-vs-tmpfs-vs-mmap

I am not entirely certain of my answer but it is plausible that you are using SHM and hence the parameter for mmap mask may not apply.

try this as well after laoding your APC.php

ls /dev/shm
Related Topic