6

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.

5
  • I experienced this problem when I set APC to 4GB on a 32bit system. When it would approach the limit, it would segfault PHP and apache didn't recover correctly. My solution was to set it down a few MB so it didn't hit the magic 4GB limit. Sep 19, 2012 at 16:43
  • Nice deduction. In this case, the box in question only had two gigs of memory. We upgraded from the VPS to a dedicated machine and the problem went away. Not as much of a solution as I'd like, but it's a result.
    – Sudowned
    Sep 19, 2012 at 16:47
  • Out of curiosity, what did you set the shm_size on the 2GB box that was causing the problem? Sep 19, 2012 at 16:53
  • I can't say with certainty. I think it was under 500MB, but I am probably wrong. It's been a while.
    – Sudowned
    Sep 21, 2012 at 18:06
  • I also experienced this error by accident and I can confirm it has to do with APC failing to allocate enough memory. A lower shm_size fixed it.
    – Mahn
    May 6, 2015 at 15:11

1 Answer 1

6

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .