10 Ways to Improve WordPress Performance on Windows

(Adopted from JessCoburn.com)

wordpressLast year I attended the San Francisco WordCamp because I wanted to see what the Core WordPress team had to say about WordPress Hosting on Windows.   Sadly, it was my experience there that they’re still not very Windows friendly.  I personally believe it’s one of two reasons:

  1. There’s still this mentality that Microsoft is Evil and out to shut down all things open-source. I wonder if they’ll ever escape from their past.  But this is the classic Open-Source versus Commercial Software debate.  Good luck if you get into one of those debates..
  2. There’s still this ASP/ASP.NET on Windows, PHP/PERL on Linux (okay maybe it’s Ruby today, whatever).

Now, since 2007 Microsoft has been working closely with Zend to make PHP performance on Windows a first class citizen.  Since that time, they’ve done a number of improvements to PHP but still today the PHP developer community is unaware of these changes and that today PHP runs quite good on Windows.

You see, In the past there was always a performance difference between PHP on Linux and PHP on Windows.  I’d love to say PHP on Windows outperforms PHP on Linux but instead I’ll simply say this, In a car race often times it’s not the car that decides who wins the race, it’s the driver.  In application hosting it’s very much the same.  So here’s a few quick tips on what to do in order to get the best possible performance of your WordPress site on Windows:

Tip #1 Use Windows Server 2008 R2

If you’re going to run PHP on Windows, the first thing you’ll want to do is make sure your running this on a Windows Server 2008 R2 server.  This is Microsoft latest build of IIS on it (7.5) and has all the latest improvements on it.  So start there.

Tip #2 Use FastCGI

In a nutshell, when you execute a CGI based application like a PHP based application, each time it’s run it has to fire up a new process. This means everything PHP needs has to be loaded for that page call and then unloaded. On the next page call, this all happens again.  FastCGI, allows CGI applications like (PHP and WordPress) to use the same process so you avoid that load up and unload of the PHP engine every time, it’s already there resident in memory just waiting for the app to be called. http://www.iis.net/download/FastCGI

Tip #3 Use non-thread-safe libraries for PHP

This is a big one.  PHP was always released for windows with thread safe libraries because Windows is a multithreaded architecture. However, when calling a CGI application from within IIS, a multiprocess architecture (similar to Linux) this contributes to slow performance.  By using the non-threadsafe libraries we get around this. http://windows.php.net/

Tip #4 Use PHP 5.3 (or later) compiled with VC9

This is another huge one. HUGE!  You’ll want to use the VC9 version of PHP because it’s compiled with the newer compiler and allows PHP to take advantage of the improvements made in Windows over the past several years.  http://windows.php.net/

Tip #5 Use WebPI to install PHP

This is just a quickie tip for you. But the other issue we commonly saw with PHP is that when people installed it, they really didn’t know how to install it properly.  Microsoft released the “Web Platform Installer” some time ago (also called the WebPI) and this provides a more standardized, best practices approach to installing PHP (it will also install the latest build with the VC9, non thread safe binaries for you and configure FastCGI as well .. that’s 4 birds, one stone!). http://www.microsoft.com/web/platform/

Tip #6 Enable WinCACHE

This is the next great improvement. The Windows Cache Extension for PHP is a PHP accelerator that allows to PHP applications on Windows to use PHP Opcode Cache, File Cache, User Cache and Session Handling. You can learn more about WinCACHE here: http://us.php.net/wincache

Tip #7 Use the newest beta build of WinCACHE

There’s a bug in the release version of WinCACHE 1.1 that requires you to reset IIS in order to do WordPress and Plugin upgrades. Basically your plugin files appear locked and you’re not able to run the installer.  You can read about that here: http://ruslany.net/2011/04/wincache-and-wordpress-plugin-upgrade-problem/

So you’ll want to go grab the latest version of WinCACHE from the link in Ruslan’s blog (he’s the man when it comes to PHP on Windows/IIS BTW)

Tip #8 Pretty Permalinks JUST WORK!

Say what?!?  That’s right, the biggest compliant you hear about WordPress on Windows is “Well my Permalinks won’t work and I need those for SEO so Windows is Useless.” That really was never the case thanks to our friends at Helicontech.com and on Windows Server 2008 thanks to the URL Rewrite Engine it’s not the case now either. In fact, WordPress out of the box supports the URL Rewrite Engine today and will automatically update the web.config for your site (it’s like the .htaccess/.htconfig file on steroids) for you!

Tip #9 Use W3 Total Cache (W3TC)

I love this plugin! You see, I’m all about KISS, Keep It Simple Stupid and W3 Total Cache does that for us. Once you install WinCACHE you still need to tell your app to use it as the OpCode cache and W3 Total Cache supports WinCACHE (and Windows of course) and makes this easy to do. You just click the drop down the box and select it.  Plus, it’s very smart to use a caching plugin with WordPress regardless of what platform you run on and this is by far one of the best.  You know how to get it of course, but if not: http://wordpress.org/extend/plugins/w3-total-cache/ oh and as your site grows and scales you’ll want to integrate it with a CDN right? W3TC makes that easy too!

Tip #10 Host With An Awesome Web Host (AppliedI.net, if you didn’t figure it out)

This is really the biggest thing. You need to host your WordPress site with a hosting provider that knows the Windows Platform, IIS, Microsoft, PHP and of course WordPress.  Believe it or not, just because your webhost was able to stand up a Windows Server with PHP on it, they aren’t necessarily a Windows Host.  Applied Innovations (www.appliedi.net) is the company I founded back in 1999 and I’ve been running PHP on Windows since 2000/2001. Today we host about 35,000 domains for 10,000 developers just like you! We use this application, (I use it for this blog) and we know it.  So find a host that knows the platform and knows the application.  BTW, about 30% of all new sites we deploy today are deploying some flavor of PHP on their hosting and most commonly that’s WordPress!

Oh and one last thing, if you want to give us a try I’ll give you the first 6 months of hosting for free: https://www.appliedi.net/webmatrix

Bonus Tip:  WebMatrix! It just makes things easy for you. It builds out an entire dev environment locally on your desktop and allows you to click one button to publish and it will send up your files, set permissions and even publish your database for you.  It will also give you a single button so you can pull down your site as easily as you published it too! you can get it from that link the previous tip.

About the Author

Jess Coburn

It's Jess's responsibility as CEO and Founder of Applied Innovations to set the direction of Applied Innovations services to ensure that as a company we're consistently meeting the needs of our customers to help drive their success. In his spare time, Jess enjoys many of the things that made him a geek to begin with. That includes sexy new hardware, learning new technology and even a videogame or two! When you can’t find him at the office (which admittedly is rare), you’ll likely find him at the grill or in front of his smoker getting ready for some lip-smacking ribs to enjoy with his wife and two kids.

5 Comments

  1. I am trying to install W3TC on a shared windows hosting environment, and it seems to me that it aint working. Any specifics around it and what to look for in case its not working?
    Thanks.

  2. You mention that installing W3 total cache on your IIS 7 Server or windows server is totally fine. Are you sure about that? I only knew that w3 total cache is using .htaccess on your server while web.config for windows server or IIS 7.

    • John, the reason it works in our environment is that we have a module for IIS that is able to parse .htaccess files for those versions below IIS7 and for IIS7 and above W3TC works fine. We have hundreds if not thousands of wordpress sites running on it in fact and several of our own sites run on wordpress on IIS7+

    • Alan, absolutely. The only things I would change are as follows:

      1) The version of PHP is obviously newer now and Microsoft helped contributed to those versions so they are better optimized on Windows.
      2) The versions of MySQL today are newer and also Microsoft helped to optimize those.
      3) winCACHE is still recommended for caching.
      4) permalinks just work

      The only thing I might change today would be possibly using redis if load balanced and some optimizations within wordpress which are wordpress specific regardless of the platform you’re hosted on.

      Plain and simple, wordpress runs extremely well on Windows and will run as fast on Windows as it will run on Linux (I’ve mastered it on both). The only issue you run into with WordPress on windows is when developers of plugins take shortcuts that are non-standard, likely performance or security impacting and leverage linux OS specific routines. That’s usually due to their inexperience and with an extremely open platform like wordpress where anyone and their brother can build a plugin and claim to be an expert developers .. it can and does happen.

      Happy WordPressing.

Leave a Reply

Your email address will not be published. Required fields are marked *