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?

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).

2 Answers
2

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/

There is no file created in /dev/shm, and no files are present in /tmp like it should be according to my configuration. So, the problem remains... but the link you provided (at nigeldunn.com) looks to be really interesting since my configuration seems to be screwed up as well (apc.php says "100% fragmentation"), so I'm gonna fix it with his advices (so, thanks about it! :) ). I'll try some experimentations about mmapping files, and let you know what happens! :P
–
Alessio PerilosoJul 4 '12 at 3:49

1

Okay, after having tested it for a while I can say: nothing happens. No files are created anywhere, and everything seems to be allocated just into the ram.
–
Alessio PerilosoMar 26 '13 at 15:20

In case it's useful to anyone, the files get deleted almost immediately which is why you can't see them via ls (unless you happen to run ls just at the right second). If you'd like to see files being created and deleted by APC in the directory specified by apc.mmap_file_mask, you can use inotify-tools to monitor filesystem activity in that directory.

Just install it and change to the apc.mmap_file_mask directory and run the following command. If other processes use that directory for other things (such as in the case of /tmp), you can pipe the output to grep and look for part of the filename that matches your mmap_file_mask setting such as 'apc.'