Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

i have nginx+php-fpm and APC installed on a freebsd server, and i'm experiencing constant problems with php-fpm connected somehow with APC. php-fpm freezes in 'lockf' state (in top) and thus site is not working. i noticed that by lowering apc.shm_size to its default value 30 is helping php-fpm not to freeze, but 30Mb is not enough for me, because i store a lot of variables in APC. i noticed that raising apc.shm_size to higher values (as 60) makes php-fpm processes to use a lot more memory, practically all of the server physical memory, which is strange because as i understood those 60Mb are shared between all php-fpm processes and should not affect on memory usage of every php-fpm process. i tried to change apc.shm_segments value to something more than 1 and got an error on restarting php-fpm:

PHP Startup: apc.shm_segments setting ignored in MMAP mode in <b>Unknown</b> on line <b>0</b><br />
Unknown(0) : Warning - PHP Startup: apc.shm_segments setting ignored in MMAP mode

so please tell me how do really those parameters affect on APC and why do php-fpm dies when using big amount of shared memory? what means MMAP mode? i'm thinking of swithing to xcache, is it working with php-fpm and stable enough for production?

share|improve this question

3 Answers 3

About mmap:

Configure script of apc has directive:

  --disable-apc-mmap
                          Disable mmap support and use IPC shm instead

Also there is 3 types of locking:

  --enable-apc-sem
                          Enable semaphore locks instead of fcntl
  --enable-apc-spinlocks
                          Enable spin locks  EXPERIMENTAL

+Default fcntl. You can try spinlocks and see what happens

PS. This should be useful too: http://www.php.net/manual/en/apc.setup.php

share|improve this answer

If you have not increased the sysctl value kern.ipc.shmmax you need to do that. By default it is 32 MB, at least in my FreeBSD 8.0 and many Linux distributions as well.

Try sysctl -w kern.ipc.shmmax=134217728 to increase to value to 128 megabytes. Then try to increase apc.shm_size again to be more than 30 MB.

If that helps, put your preferred kern.ipc.shmmax value to /etc/sysctl.conf to make the change persist between reboots.

share|improve this answer
    
I get error: "kern.ipc.shmmax" is an unknown key at ubuntu 11.10 oneiric –  john Oct 6 '11 at 14:22
    
@john: you can find the known keys under /proc/sys. On my machine it was kernel.shmmax. (It did not make the error go away, though.) –  Tgr Aug 21 '12 at 17:10

How did you set the memory?

apc.shm_size=64 or apc.shm_size=64M, as it is in the manual?

The latter solved my similar problem.

share|improve this answer
1  
M or not M, depends on apc/php version I think –  john Oct 6 '11 at 14:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.