Tuning APC

Configuration

  • Old opcodes stay in cache until all old requests satisfied. Leave headroom (up to 2x normal size).
  • Add hints
  • Set apc.stat = 0
    • But have to restart server to get new files
  • With source control, use apc.stat_ctime = 1 if apc.stat = 1.
  • Compile using spin locks. Use pthreads if spins fail.

Ideas

  • Try experimental functions apc_bindump_file() and apc_binload_file().
  • On deployment, serialize the cache and load in the serialized cache to every server while under maintenance.
  • Use apc_compile_file() to prime/update the cache.
  • User variable cache: apc_fetch(), but must serialize to use memcached.
  • Check if latest APC uses double-linked lists for less performance trouble with fragmentation.
  • Check out lazy loading (a PHP 5.3 patch).
  • Use APCIterator().
  • Check out APC 4.0 with LFU support, which supports multiple caches.

Other notes

  • No sharing of compiled code between FastCGI threads
  • Significant copying of compiled code between Apache/mod_php threads