LiteSpeed Cache + Mediawiki

Discussion in 'LiteSpeed Cache' started by webizen, Feb 26, 2011.

  1. webizen

    webizen New Member

    MediaWiki

    MediaWiki is a free software open source wiki package written in PHP, originally for use on Wikipedia (the free encyclopedia). It is a feature-rich wiki implementation, that uses PHP to process and display data stored in its MySQL database. It is fairly popular wiki application on the web.

    MediaWiki Cache

    With its complexity, page rendering usually takes time. To mitigate these costs, many caching solutions have been brought up and implemented. This page (http://www.mediawiki.org/wiki/Manual:Cache) gives a good overview of caching in mediawiki. Among them, page caching is the one with the most performance gain. Varnish/Squid + Mediawiki is good combination. This page (http://www.mediawiki.org/wiki/Manual:Varnish_caching) talks setup varnish with Mediawiki in details.

    LiteSpeed Cache + MediaWiki

    We here in LiteSpeed have implemented a very simple page caching solution using LiteSpeed built-in cache for MediaWiki. Below we will outline the implementation in details and provide benchmarks with Varnish cache in the end.

    As everyone may know, LiteSpeed webserver (LSWS) cache bypasses php invocation and serves cached page directly from LSWS cache. Hence a much bigger performance improvement can be achieved. The general guideline of using LSWS cache is available at http://www.litespeedtech.com/support/forum/showthread.php?t=4719. Unlike Varnish, it is built into LiteSpeed web server, eliminating one layer of reverse proxy. Hence more efficient for static contents.

    In MediaWiki, everything going through index.php for processing. Using the guideline "A general way to enable LiteSpeed Cache through rewrite rules is to designate a signature token (such as cookie) in a page (or any page) in most cases to tell LSWS that cache can be enabled and TTL(Time To Live) of the cache freshness however acceptable. ", we find out that, for anonymous visitors (people who don’t log in to the site), any page with no query string in URL is cacheable using LiteSpeed cache.

    That said, we come up with a simple set of rewrite rules in .htaccess for page caching as follows:
    %%
    Explanation:
    1. Cache HEAD and GET requests
    2. For cookie that does NOT contain "wikidbUserID". (anonymous visitors)
    3. Request does NOT contain query string
    4. Cache TTL is set to 300 seconds (5mins).

    Verification

    If a resource is served from LSWS cache, the server response header contains 'X-LiteSpeed-Cache: Hit'.

    Benchmarks

    Follow the guide (http://www.mediawiki.org/wiki/Manual:Varnish_caching), we have Varnish set up on port 2080 in front of LSWS which serves MediaWiki.

    AB test results are as follows:

    LSWS (cache disabled) + MediaWiki

    Varnish + LSWS (cache disabled) + MediaWiki

    LSWS Cache + Mediawiki

    As shown, LSWS Cache + MediaWiki is ~150% faster than Varnish + MediaWiki.
    Last edited: Feb 26, 2011

Share This Page