Php – APC not caching many files

cachePHP

I have a Drupal site running on a VPS at Linode with PHP 5.2.10 and APC 3.1.6.

It never caches more than about 25 files and barely uses any of its available memory. Drupal has hundreds of PHP files. I have another server where APC seems to work well and does indeed cache hundreds of files. The only difference with that site is that it runs Ubuntu 10.04 and php 5.3.2. The config settings are the same.

What could be wrong? I'll paste the config from apc.php below. This is after hitting multiple parts of Drupal.

APC Version 3.1.6
PHP Version 5.2.10-2ubuntu6.5
APC Host    xxx.example.com
Server Software Apache/2.2.12 (Ubuntu)
Shared Memory   1 Segment(s) with 32.0 MBytes
(mmap memory, pthread mutex locking)
Start Time  2010/12/02 11:32:17
Uptime  3 minutes
File Upload Support 1
File Cache Information
Cached Files    21 ( 1.4 MBytes)
Hits    169
Misses  21
Request Rate (hits, misses) 1.00 cache requests/second
Hit Rate    0.89 cache requests/second
Miss Rate   0.11 cache requests/second
Insert Rate 0.17 cache requests/second
Cache full count    0
User Cache Information
Cached Variables    0 ( 0.0 Bytes)
Hits    0
Misses  0
Request Rate (hits, misses) 0.00 cache requests/second
Hit Rate    0.00 cache requests/second
Miss Rate   0.00 cache requests/second
Insert Rate 0.00 cache requests/second
Cache full count    0
Runtime Settings
apc.cache_by_default    1
apc.canonicalize    1
apc.coredump_unmap  0
apc.enable_cli  0
apc.enabled 1
apc.file_md5    0
apc.file_update_protection  2
apc.filters 
apc.gc_ttl  3600
apc.include_once_override   0
apc.lazy_classes    0
apc.lazy_functions  0
apc.max_file_size   1M
apc.mmap_file_mask  
apc.num_files_hint  1000
apc.preload_path    
apc.report_autofilter   0
apc.rfc1867 0
apc.rfc1867_freq    0
apc.rfc1867_name    APC_UPLOAD_PROGRESS
apc.rfc1867_prefix  upload_
apc.rfc1867_ttl 3600
apc.shm_segments    1
apc.shm_size    32M
apc.slam_defense    1
apc.stat    1
apc.stat_ctime  0
apc.ttl 0
apc.use_request_time    1
apc.user_entries_hint   4096
apc.user_ttl    0
apc.write_lock  1

Best Answer

Increase these two values in the config file: apc.shm_segments 1 apc.shm_size 32M

you'll need to restart php/apache to see the effect.

Related Topic