Peter Mann
Peter Mann

Reputation: 11

APC Purge Rate & Fragmentation

I have got a Magento running on Nginx, PHP-FPM, Varnish & APC setup.

APC is running high on both fragmentation and purge rate.

Fragmentation increases in 2 hours >50% and slowly goes to 100%.

Even more disturbin is the fact and Munin shows that the purge rate is almost in 100% all the time.

I tried to increase the shm size to 1G (APC normally uses about 200M of this, total RAM is 6G) which didn't help, as well tried to tweak the ttl:s without any luck.

Is there something in varnish that is causing the constant purging of APC?

Here is my APC.ini

extension = apc.so
apc.enabled=1
apc.shm_segments=1
apc.shm_size=1024M
apc.num_files_hint=10000
apc.user_entries_hint=10000
apc.max_file_size=5M
apc.stat=0
apc.enable_cli = 1
apc.optimization=0
apc.cache_by_default=1
apc.slam_defense=0
apc.include_once_override=0
apc.ttl=3600
apc.user_ttl=7200
apc.gc_ttl = 600

apc.php:

**File Cache Information**
Cached Files    1053 ( 58.1 MBytes)
Hits    40172
Misses  1038
Request Rate (hits, misses) 102.26 cache requests/second
Hit Rate    99.68 cache requests/second
Miss Rate   2.58 cache requests/second
Insert Rate 10.41 cache requests/second
Cache full count    0

**User Cache Information**
Cached Variables    74 ( 1.2 MBytes)
Hits    374
Misses  5907
Request Rate (hits, misses) 15.59 cache requests/second
Hit Rate    0.93 cache requests/second
Miss Rate   14.66 cache requests/second
Insert Rate 0.18 cache requests/second
Cache full count    0

Upvotes: 1

Views: 1000

Answers (1)

Synchro
Synchro

Reputation: 37750

One trick I've found effective in keeping APC sane is to set gc_ttl to 600, as you have, but keep ttl at 0. This is less efficient and could theoretically cause stampedes on a very busy site, but it stops fragmentation building up. You also need to keep your purge rate down by making sure you're not placing too much stuff in the cache (i.e. allocate it enough memory).

This may sound counterintuitive, but here's what happened when I switched to this approach on a server today:

Cache hit ratio Fragmentation Purge rate

This munin plug-in is great for monitoring how APC changes over time, much better than trying to decipher the apc status page.

Upvotes: 1

Related Questions