APC

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 and multiple application servers.

For smaller wikis, however, which MediaWiki seems to attract more of each month, it isn't so tuned out of the box. This page contains a few useful tips on performance tuning for sites using MediaWiki.

Install APC
One of the best immediate performance improvements that can be made is to speed up execution of the application itself. This is done using a PHP accelerator, such as APC.

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 not insignificant initialisation 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. 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 phpinfo; function, 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.