APC + FPM memory fragmentation without a reason
Posted
by
palmic
on Server Fault
See other posts from Server Fault
or by palmic
Published on 2011-11-25T23:54:46Z
Indexed on
2011/11/26
1:54 UTC
Read the original article
Hit count: 672
My setup @ debian 6-testing is: nginx 1.1.8 + php 5.3.8 + php-fpm + APC 3.1.9
Because i use automatic deployment with apc_clear_cache() after deploy, my target is to set up APC to cache all my project (up to 612 php files smaller than 1MB) without files changes checking.
My confs:
FPM:
pm.max_children = 25
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 10
pm.max_requests = 500
APC:
pc.enabled="1"
apc.shm_segments = 1
apc.shm_size="64M"
apc.num_files_hint = 640
apc.user_entries_hint = 0
apc.ttl="7200"
apc.user_ttl="7200"
apc.gc_ttl="600"
apc.cache_by_default="1"
apc.filters = "apc\.php$,apc_clear.php$"
apc.canonicalize="0"
apc.slam_defense="1"
apc.localcache="1"
apc.localcache.size="512M"
apc.mmap_file_mask="/tmp/apc-php5.XXXXXX"
apc.enable_cli="0"
apc.max_file_size = 2M
apc.write_lock="1"
apc.localcache = 1
apc.localcache.size = 512
apc.report_autofilter="0"
apc.include_once_override="0"
apc.coredump_unmap="0"
apc.stat="0"
apc.stat_ctime="0"
The problem is i have my APC memory fragmented into 5 pieces at 14,5MB loaded into memory which capacity is 64M. My system memory is 640MB, used about 270MB at most.
The http responses lasts about 300ms - 5s.
When i switch on apc.stat="1"
, the responses are about 50ms - 80ms which is quite good, but i cannot understand why is apc.stat="0" so much whorse.
The APC diagnostic tool shows "1 Segment(s) with 64.0 MBytes (mmap memory, pthread mutex Locks locking)" in general cache information window so i hope i am right that it's mmap setup which allows tweaking APC shm onto upper values than shows system limit in /proc/sys/kernel/shmmax (my shows 33MB).
© Server Fault or respective owner