APC does not speed up PHP 5.4

I had this problem before on WAMP Server and PHP 5.3 , and now run into it on Linux using PHP 5.4.

Basically, APC is on or off, it doesn't matter at all in performance, even though the statistics in apc.php say.

Here is a sample test script that includes over 30 PHP Doctrine files and time:

$t = microtime(true); include 'Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'; printf('%.3f s', microtime(true)-$t); 
  • Result on Windows (Zend Server CE, PHP 5.4): 0.001 s
  • Result on Linux (PHP 5.4 and APC 3.1.11): 0.106 s

Note. Even if this does not appear in the above script, I actually use the full path to the file and do not rely on include_path.

The result I get on Linux is the same as apc.enabled - 0 or 1 , so it seems that caching the operation code just doesn't work.

However, apc.php says:

apc.php

Packages (from repository repository , CentOS 6.3):

 php-5.4.5-1.el6.remi.x86_64 php-pecl-apc-3.1.11-1.el6.remi.1.x86_64 

APC Configuration:

 apc.enabled=1 apc.shm_segments=1 apc.shm_size=64M apc.num_files_hint=1024 apc.user_entries_hint=4096 apc.ttl=7200 apc.use_request_time=1 apc.user_ttl=7200 apc.gc_ttl=3600 apc.cache_by_default=1 apc.file_update_protection=2 apc.enable_cli=1 apc.max_file_size=1M apc.stat=1 apc.stat_ctime=0 apc.canonicalize=0 apc.write_lock=1 

Last thing, yes, PHP tells APC to be included:

 var_dump(extension_loaded('apc')); // (bool) true 
+6
source share
1 answer

I forgot to mention an important part of the problem: the web server runs on a Linux virtual machine in Windows 7 and reads files from a shared folder on the host.

I noticed that what slows down APC has stat files in this shared folder.

Copying files to a virtual machine fixes the problem.

I am surprised that apc.stat=0 does not fix the problem alone, I would expect it to be stat only once, and unconditionally read everything from the cache in memory.

+3
source

Source: https://habr.com/ru/post/921563/


All Articles