# Slow load of Mediawiki landing page in IIS8 using PHP, MySQL, FastCGI

• ### Question

• User-1602494344 posted

I've read a lot of posts regarding this issue where a PHP website (in my case Mediawiki), takes between 10 - 15 seconds to load when browsing the landing page for the first time in a session. While there are a lot of suggestions of configuring output_buffering in PHP, DNS resolution in MySQL, PHP caching using Wincache or APC, short of using Apache (which is not an option), I have yet to find a working solution. I have gone through every iteration of Mediwiki fine tuning, and to the best of my knowledge, fine tuning of MySQL, PHP and IIS. I don't believe that any of individual technology is causing the bottleneck, but I feel that the protocol interfaces between the different technologies (e.g PHP Manager for IIS, FastCGI, or URL Rewrite) could be the issue. I have tried to come at this from different angles, have upgraded hardware and used different servers with Server 2008 R2 and Server 2012, all with exactly the same result.

It's interesting to note that on both environments, with different OS' and hardware configurations (memory, RAID etc), the time to load is exactly the same - around 15 seconds. It's like there is a sequence of events that need to sequentially transpire in order for the site to finish loading. My setup is as follows:

1. Windows Server 2012 x64 with IIS 8
2. PHP v5.4.14 (x86) Non Thread Safe for compatibility requirements for Wincache
3. MySQL 5.5 (x64), administered with MySQL Workbench 5.2
4. Mediawiki 1.20.2

Additional information regarding my server components are:

• IIS URL Rewrite
• IIS PHP Manager
• IIS FastCGI
• Wincache enabled
• 8GB Memory with RAID 10 configuration

Not sure what else is relevant, but I'm hoping that there is a property or configuration that needs to be enabled that will provide the solution. All help is greatly appreciated, and I look forward to documenting the resolution.

Tuesday, July 23, 2013 2:18 AM

• User-1602494344 posted

Success!! I have been able to achieve the response times that I was looking for, without having to move off the Microsoft platform. To resolve this issue, I did the following:

1.  One of the biggest impacts, reducing the load from 15 seconds down to around 6 or 7 was to enable Mediawiki caching and acceleration, as detailed in this post: http://www.charlesrcook.com/archive/2012/09/12/mediawiki-iis7-output-caching-and-friendlyshort-urls.aspx. In short, enable the following in your Mediawiki localsettings.php file:

$wgCacheDirectory = "c:\your\path\to\cache";$wgFileCacheDirectory = "c:\your\path\to\cache ";
$wgEnableSidebarCache = true;$wgUseFileCache = true;
$wgShowIPinHeader = false;$wgEnableParserCache = true;
$wgCachePages = true;$wgMainCacheType = CACHE_ACCEL;
$wgMessageCacheType = CACHE_ACCEL;$wgParserCacheType = CACHE_ACCEL;
$wgMemCachedServers = array(); Make sure your local IUSR and IIS_IUSR accounts have "Modify" permissions on the cache directory, or else the files and directories from Mediawiki caching engine will not be able to write to them. 2. I made some minor changes to caching in PHP using Wincache, but that hardly had any affect - enable and configure it if you wish from a PHP perspective, but don't expect a major jump. The same thing goes for MySQL query caching - my Wiki site is relatively small, with minimum usage, so MySQL query caching wasn't a huge improvement. 3. The final nail in the coffin to bring the site up to speed was modifying the$wgDBserver setting in my Mediawiki LocalSettings.php file. It was set to "Localhost", and this post http://forums.iis.net/t/1153459.aspx/3/10 suggested that using "Localhost" on Windows 7 onwards, and Server 2008 onwards starts getting IPv6 involved in the querying of the page.  The transport layer had to resolve localhost and was doing so by negotiating between an IPv4 and an IPv6 address,  which PHP and MySQL needed to resolve before allowing the page to render. It appears that this is still not a fully supported integrated protocol, so setting \$wgDBserver to the IPv4 address of "127.0.0.1" took the rendering from 6 seconds to just on 1 second - problem solved!

Having IIS, Mediawiki, PHP and MySQL all on one Windows Server 2008 or Server 2012 does work, once the above settings are applied.

• Marked as answer by Tuesday, September 28, 2021 12:00 AM
Wednesday, July 24, 2013 2:17 AM