Reputation: 150
I've just installed APC to cache my PHP code on my Ubuntu VPS server. Using
sudo apt-get install php-apc
sudo /etc/init.d/apache2 restart
This worked fine. However, I encounter some problems increasing the chunk of RAM allocated to APC. If I run apc.php it gives me this information about the shared memory.
Shared Memory 1 Segment(s) with 30.0 MBytes (mmap memory, pthread mutex locking)
Even though I configured
apc.shm_segments 3
Not setting the default
apc.shm_size 30
In addition I've got the problem that as soon as I set apc.shm_size
in apc.ini
or php.ini
apache hangs on restart/graceful and wont come up.
My questions:
1. If the memory allocated to APC is apc.shm_size * apc.shm_segments
why can I only see 90M?
2. Has got anyone had the problem with the hanging Apache on setting of apc.shm_size
? How would I fix that?
Many thanks!
Upvotes: 3
Views: 6493
Reputation: 150
Seems like i found the problem
sudo apt-get install php-apc
sudo /etc/init.d/apache2 restart
Installed an old version of APC
on my machine. In that version apc.shm_size=30M
has to be configuered without the M in the memory size. Thus new versions of APC use apc.shm_size=30M
old version apc.shm_size=30
. Once I made the change Apache restarted without a glitch.
Upvotes: 5
Reputation: 30496
You should check the kernel max size for shared memory. On debian-like distribution it's quite low (and ubuntu is a debian-like). Altering it via sysctl.conf could help you.? Get current value with:
sysctl -a | grep shmmax
It's a value in Bytes.
This could explain apache crash when you set a too big number (but you should have something about it in error.log).
Seem for this response that apc.shm_segments
is not always used by APC. We can see some explanations here: http://www.php.net/manual/fr/apc.configuration.php#94529:
If you've configured APC to use memory mapped files (with the --enable-mmap option), the shm_segments setting is ignored unless you specify a file mask via the mmap_file_mask setting. Which could be fixed by giving a value to
apc.mmap_file_mask
configuration setting (see link).
But as said in this comment, using several shared segments is certainly worst as using a big one. there is at least two big application which makes heavy use of big shared memory and which always needs an alteration of the kernel settings for that, it's Varnish and PostgreSQL. Both made the choice of using a big shared segment instead of several.
Upvotes: 4