Alexey2013-05-10 13:34:15
Alexey, 2013-05-10 13:34:15

After disabling APC on a web server with LAMP, sites began to work faster and the processor was offloaded. wtf?

Hello colleagues and comrades.

We have a web server on CentOS 6.3 for hosting a number of sites on Drupal (mainly the seventh version), where the traditional LAMP + nginx is rolled up as a reverse proxy. APC was used as a precompiler for PHP. There are about 100 live sites on the server, there is no high load.

Most of the sites on the web server are recent, before that there were 5-6 sites and everything worked well (with the same APC). But when a lot of sites came (and all the newcomers are weak, 100 hosts per day), we began to notice periodic slowdowns: the same site loaded either normally, or with a dullness (and it was not possible to reproduce the dullness unambiguously). But when the sites started firing notices like Unable to allocate memory for pool...- they found the culprit, it turned out to be APC (that is, probably not him, but our imperfectdefault configs, but nevertheless).

The situation developed like this: The


fuss with the settings came down mainly to apc.shm_*, but the situation with the load on the processor did not solve it.

The full config at the time of shutdown was as follows:

APC Configuration

# cat /etc/php.d/apc.ini <br>
; Enable apc extension module<br>
extension = apc.so<br>
; Options for the APC module version >= 3.1.3<br>
; See http://www.php.net/manual/en/apc.configuration.php<br>
; This can be set to 0 to disable APC. <br>
; The number of shared memory segments to allocate for the compiler cache. <br>
; The size of each shared memory segment, with M/G suffixe<br>
; A "hint" about the number of distinct source files that will be included or <br>
; requested on your web server. Set to zero or omit if you are not sure;<br>
; Just like num_files_hint, a "hint" about the number of distinct user cache<br>
; variables to store.  Set to zero or omit if you are not sure;<br>
; The number of seconds a cache entry is allowed to idle in a slot in case this<br>
; cache entry slot is needed by another entry.<br>
; use the SAPI request start time for TTL<br>
; The number of seconds a user cache entry is allowed to idle in a slot in case<br>
; this cache entry slot is needed by another entry.<br>
; The number of seconds that a cache entry may remain on the garbage-collection list. <br>
; On by default, but can be set to off and used in conjunction with positive<br>
; apc.filters so that files are only cached if matched by a positive filter.<br>
; A comma-separated list of POSIX extended regular expressions.<br>
apc.filters =  "-(.*)\.tpl\.php$, -(.*)/apc\.php$"<br>
; The mktemp-style file_mask to pass to the mmap module <br>
; This file_update_protection setting puts a delay on caching brand new files.<br>
; Setting this enables APC for the CLI version of PHP (Mostly for testing and debugging).<br>
; Prevents large files from being cached<br>
; Whether to stat the main script file and the fullpath includes.<br>
; Vertification with ctime will avoid problems caused by programs such as svn or rsync by making <br>
; sure inodes have not changed since the last stat. APC will normally only check mtime.<br>
; Whether to canonicalize paths in stat=0 mode or fall back to stat behaviour<br>
; With write_lock enabled, only one process at a time will try to compile an <br>
; uncached script while the other processes will run uncached<br>
; Logs any scripts that were automatically excluded from being cached due to early/late binding issues.<br>
; RFC1867 File Upload Progress hook handler<br>
apc.rfc1867_prefix =upload_<br>
; Optimize include_once and require_once calls and avoid the expensive system calls used.<br>
; Enables APC handling of signals, such as SIGSEGV, that write core files when signaled. <br>
; APC will attempt to unmap the shared memory segment in order to exclude it from the core file<br>
; Records a md5 hash of files. <br>
; not documented<br>

As a result, APC was completely deactivated. The blunt sites disappeared, the processor was unloaded. "By eye" we do not see slower operation of sites, and therefore, until the circumstances were clarified, we left the server without an accelerator at all.

Colleagues, please share your experience on the topic (it can be bitter too) and tell me in which direction to turn the APC configs?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
Puma Thailand, 2013-05-10

You are using some terribly large amount of memory for apc
it seems to me that it just searches the cache longer than it gives the code.

Maxim, 2013-05-10

Unable to allocate memory for pool - you dig into their bugzilla, there are thousands of them. I am desperate to get APC to work properly in production using eAccelerator and XCache. I recommend to take fresh XCache.

egorinsk, 2013-05-10

PHP accelerators suffer from bugs. You are still lucky if he only ate memory, it happens that the PHP process crashes with a random probability and you won’t guess that the op cacher is to blame.

UncleByte, 2013-05-11

So he was already disabled at the time of the "shutdown"?

; This can be set to 0 to disable APC. 

Or was it still included with that crazy amount of memory from the config?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question