MediaWiki is quite complex package, and some even trivial features are not the ones that should be enabled on sites having more load. Though it is quite modular, still lots of code has to be executed, and some of it requires additional steps to be done.
I did my tests on simple desktop – not some fancy server, so your mileage may vary. Primary benchmark was the “served in” timer at the bottom of each MediaWiki page source, and it may not be perfect one.
So, with fresh PHP 5.2.0 install (on top of lighty), it took 217ms to render the default Main Page. It is quite huge amount of time, as for such small text, but once all internals are taken into mind, one could see that there’s lots of source code to parse and various bits to cache. For that we install APC – it will cache both compiled bytecode of PHP script and internal MediaWiki objects:
- pecl install APC
- add extension=apc.so to php.ini
- add $wgMainCacheType = CACHE_ACCEL; into LocalSettings.php
This way we cut the execution time to… 50ms.
Our next step is to disable ‘visits’ counter, that displays number of visits at each page. After $wgDisableCounters=true is in our configuration file, execution time is cut to 40ms.
A final touch for now is editing MediaWiki:Aboutsite, Aboutpage, pagetitle, pagetitle-view-mainpage, opensearch-desc tagline, tooltip-search system messages, and changing {{SITENAME}} into your proper site name. Parsing curly braces adds milliseconds, and now the page rendering is just 37ms.
Of course, once it runs on multiple servers, then different caching techniques apply, but for single server this helps a lot.
Update (2009/09/07): With 1.16 (and releases since I wrote the article) there’re more performance settings:
- $wgCacheDirectory=’./cache/’ (it will enable awesome localization caching code – though may be much better if directory is protected from web access).
- $wgEnableSidebarCache=true; – caches rendered sidebar
- $wgEnableTooltipsAndAccesskeys=false; – disable tooltips and access keys (I just added this toggle, I just wanted to know it is possible to turn these things off).
Now my MediaWiki test deployments seem to enjoy ~20ms rendering times. A bit better.
Maybe you should add that on http://www.mediawiki.org under a new article
named “performance tunning” :)
This is gold! I created http://www.mediawiki.org/wiki/Manual:Performance_tuning , also mentioning http://www.mediawiki.org/wiki/User:Robchurch/Performance_tuning which also talks about APC. Please update that.
I want to thank you so MUCH for this! I had setup a mirror of wikipedia that was frankly unusable!!!
However just from your page, and the simple how to setup APC my load time went from 1-2 minutes per page to just seconds!!!!
This whole thing makes mediawiki usable!
I just want to thank you yet again!