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.

Sudowned
  • 288
  • 1
  • 3
  • 13
  • 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. – Kendall Hopkins Sep 19 '12 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 '12 at 16:47
  • Out of curiosity, what did you set the `shm_size` on the 2GB box that was causing the problem? – Kendall Hopkins Sep 19 '12 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 '12 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 06 '15 at 15:11

1 Answers1

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.

Mikko Rantalainen
  • 858
  • 12
  • 27