PHP/APC fatal error, apc_mmap: mmap failed

alternative-php-cacheapache-2.2PHP

I'm seeing some intermittent CPU usage spikes to 100%, sort of correlated to these log entries:

[27-Feb-2012 13:29:29] PHP Fatal error:  PHP Startup: apc_mmap: mmap failed: in Unknown on line 0
[27-Feb-2012 13:29:30] PHP Fatal error:  PHP Startup: apc_mmap: mmap failed: in Unknown on line 0
[27-Feb-2012 13:29:31] PHP Fatal error:  PHP Startup: apc_mmap: mmap failed: in Unknown on line 0
[27-Feb-2012 13:29:31] PHP Fatal error:  PHP Startup: apc_mmap: mmap failed: in Unknown on line 0

phpinfo() indicates that APC is set up, and as far as I can tell this error doesn't cause visible 500 errors on the live site, which is a WordPress install that gets about 600k views monthly. Google's been unhelpful so far, and I was hoping that someone here had some insight as to what's causing this and how to fix it. Curiously, this error only shows up /usr/local/apache2/logs/error_log and not the error_log for the cpanel-configured site.

Best Answer

If this does not cause visible errors on the site, it must happen so early during the apache child process creation that no request has been transferred to the child before the error. Googleing for the error message suggests (http://www.litespeedtech.com/support/forum/showthread.php?t=4242) that your APC configuration is incorrect and you should check following configuration parameters:

apc.enabled = 1
apc.shm_size = 48 ;; MB, make sure that this is allowed by the system
apc.include_once_override = 1 ;; test both values
apc.mmap_file_mask = /tmp/apc.XXXXXX ;; verify mask if you use file backed storage

I'd guess some APC process is requesting more SHM mmap'ed memory than the kernel or system config is willing to provide.

Related Topic