Configure Alternate PHP Cache (APC) for Drupal

APC is an op-code caching sytem for Apache servers. The more Drupal modules you enable, the greater the need for such PHP pre-processing. Most PHP accelerators work by caching the compiled bytecode of PHP scripts to avoid the overhead of parsing and compiling source code on each request (some or all of which may never even be executed). To further improve performance, the cached code is stored in shared memory and directly executed from there, minimizing the amount of slow disk reads and memory copying at runtime.

Please download the performance script below, to check on your APC installation. Be sure monitor performance: too little RAM available for APC will hurt your site performance!

Sensible default apc.ini settings

These settings provide 128MB of APC caching and should be enough for up to 100 Drupal modules

extension=apc.so
apc.shm_size=128
apc.enabled=1
apc.shm_segments=1
apc.ttl=7200
apc.user_ttl=7200
apc.apc.stat = 0
apc.include_once_override = 1

Advantages

  • Speeds up Drupal script compilation
  • Reduces server resource usage

Disadvantages

  • Requires custom server tuning

References

Morningtime