In my work PHP is a required part of most, if not all web sites I help with; especially Drupal. Here are tips I've collected along the way and of course YMMV (your mileage may vary).

PHP Tuning

  • Utilize Op-code caching like APC, eAccelerator, Xcache, or Zend Accelerator. APC is my favorite and has been reported as the most stable and has good performance.
  • Run PHP in FastCGI (FCGI) mode versus regular CGI methods, if possible. FCGI uses a socket to the PHP process, not forking.
  • Disable PHP extensions not needed.
  • Disable debug/development extensions on production & staging servers.

APC (Alternative PHP Cache)

The Alternative PHP Cache (APC) is a free and open op-code cache for PHP. The behavior of these functions is affected by settings in php.ini. The bundled apc.php script provides a detailed analysis of how APC is working.

  • Increase apc.shm_size higher than the default 30MB. Drupal sites use 64MB or higher; 96MB is usually good enough.
  • Increase apc.num_files_hint 1024 works for Drupal, some sites may need higher than the default 1000 and can go up to 20000. Start small first.
  • Increase apc.user_entries_hint the default 4096 can be enough, this is another that can go up to 20000 if ncessary.
  • Enable apc.enable_cli to help speed up PHP scripts that run via the command line.
  • Enabling apc.include_once_override speeds scripts up but be warned: updated and new files will not be cached until APC is flushed.
  • Enabling apc.rfc1867 provides upload progress data to PHP, giving better user experiences on web pages during large file uploads.
  • Leave apc.max_file_size at the default 1MB.
  • Carefully use apc.filters to exclude file extensions that should not be cached by APC.
  • Disabling apc.stat will boost speed but new/updated files will not be recognized unless APC cache is rebuilt. Do not try this for fun; advanced use only.
Your rating: None Average: 4 (1 vote)

Tags: PHP