APC

APC is a PHP accelerator, very useful for MediaWiki: one of the best immediate performance improvements that can be made is to speed up execution of the application itself.

The original APC provides PHP bytecode caching and object caching services to PHP applications.

From PHP 5.5.0 on, PHP includes OPcache for bytecode caching. OPcache does not provide object caching services for PHP applications though; APCu can provide these missing services to applications.

Context
MediaWiki is capable of scaling to meet the needs of large wiki farms such as those of the Wikimedia Foundation, Wikitravel and Wikia and can take advantage of a wide number of methods including multiple load-balanced database servers, memcached object caching, front-end Squid caches (see Manual:Squid caching) or Varnish caches (see Manual:Varnish caching) and multiple application servers. For most smaller installations, this is overkill though, and simply optimizing PHP performance is sufficient for good results.

Install APC
As of PHP 5.5.0, APC is unmaintained and has been superseded by the combination of OPcache (for PHP bytecode caching) and APCu (an object caching API for PHP applications).

APC (Alternative PHP Cache) is a bytecode cache, that is, it stores the compiled bytecode from the PHP interpreter for future runs of the same script file. A large application such as MediaWiki, which has a substantial initialization time, benefits from using such an extension rather noticeably.

The exact preferred method for installing APC depends on your platform; it can be installed from PECL in the standard fashion, or compiled and installed manually. It's not bundled in PHP 5.5. Many Linux distributions offer packages for APC which are typically installed in the same fashion as PHP itself.

Once APC is installed and running, which can be verified in the output of the  command, MediaWiki needs no special configuration to benefit from the bytecode caching capabilities it offers. However, APC also offers a "user cache", which allows application developers to store object data in the in-memory cache, rather like a "mini memcached", and MediaWiki can take advantage of this to use as a parser, message and general-purpose cache.

To configure MediaWiki to use the APC user cache, edit LocalSettings.php and add the following line:



A script, apc.php is bundled with the APC package which can be used to inspect the status of the cache, and also examine the contents of the user cache to verify that MediaWiki is correctly using it.

Caveats

 * The APC user cache is not suitable for use in environments where multiple application servers are used.
 * All PHP applications on the server are able to access the same user cache, thus, if multiple users are using the server to run web applications, they are able to read the values of the user cache, which could lead to information being taken from the cache. This might include serialized user objects, for example, containing email addresses, password hashes and edit tokens.

MediaWiki will still benefit from APC's bytecode caching features if you decide not to configure it to use the user cache, however, so it is still well worth installing.