35

With the new WordPress and it's new features, it seems like WordPress is capable of much more than a simple blog engine. But how well does WordPress scale being used by say 10k -> 100k users per day?

With that many users a big part of it will be to have a good cache strategy, but how well is WordPress developed to help, making this easy and give you the control you need. Fx being able to cache part of a page and only render user customized parts, support master/slave db setup and stuff like that?

3 Answers 3

37

Clearly nothing scales as well as static files served by a fast web server and any CMS that has to figure out what to load and then load it will not perform as well, WordPress or otherwise. One of the issues is the number of database queries required per URL request and my 2 prior years experience working exclusively with Drupal and now 2+ years with WordPress is that WordPress is much better in that department.

That said, almost nothing with any power is going to scale "out-of-the-box"; it's all about what can you do as your scalability needs grow?

On the low end of "lots of traffic" there are great caching plugins and integrations with inexpensive CDNs you can do a pretty good job on a no-IT budget and low hosting budget. Here are some other questions & answers to review:

There are options for profiling to identify performance bottlenecks:

Once bottlenecks are identified you can do localized optimization with things like the Transients API. This Q&A gives an example that can be optimized using Transients API and shows how:

If you thing really get want to pull out the big guns you can configure Memcached, HyperDB, Nginx and/or more to speed things up (it seems the latter is really evolving into the way to get amazing scalability out of WordPress):

And finally there are emerging WordPress-focused webhosts specializing in performance such as WP Engine, ZippyKid and others:

So the good news is all of the scales very nicely; from the very low end of free and easy with technical complexity and cost only grow as traffic significantly grows. Start small with WordPress and it will be great. If your traffic does grow and you are monetizing it even reasonably well you'll find it very cost effect to scale as you need it.

At least IMO. :)

4
  • Thanx for such a thorough response. I wonder, how is the WordPress APIs to work with, caching parts of a page - so you only need to generate the user specific parts and not the entire page for logged in users or using Edge Side Includes for the high traffic sites.
    – user94
    Sep 2, 2010 at 9:56
  • Mike, you are a beast! Everywhere I go on this site, I come across your answers and they're all great!
    – dgw
    Sep 2, 2010 at 22:28
  • @googletorp: You definitely can do that, it just takes hand-crafted code. I'd love to see if a framework could be developed to make it easier but I'm currently focused on trying to implement robust and feature-rich custom post fields. Maybe sometime soon. :) @Voyagerfan5761: Thanks. :) Sep 3, 2010 at 8:21
  • kiragiannis.com/cloud-computing/… This might bring some metrics to the conversation.
    – Geo
    Nov 10, 2011 at 21:35
4
  1. Don't expect much from shared hosting--don't blame WordPress for slowness if you're on a shared host. Shared hosts might cram 1000s of accounts into one server. So you can spend all day optimizing a $10/month account and it won't matter. Also watch out for marketing buzzwords--just because it says "cloud" doesn't mean you're not sharing one server with 100s or 1000s of people.

  2. I don't think cache plugins are necessary at this point. If you look at the WP source code, there's already advanced caching baked into the core. A cache of the cache of the cache of the cache--watch out, this can be counterproductive.

  3. The main thing slowing you down is slow MySQL queries and WordPress out-of-the-box shouldn't give you trouble here. However, I had to "LIMIT" my comment queries because I had 50,000+ comments. (Is this fixed yet?) Also, if you're doing anything atypical (like 1000s of categories?) that could be a problem too.

  4. I use a Linode 512 with NginX and "top" shows PHP and NginX doing their work in less than 1/100th of a second per request. Nearly all the CPU time is tied up with MySQL. You could serve 1 million pages per month with a $20 Linode, but once you start adding plugins and photos, I think you'll need a "1GB" Linode. From my point of view, it's pretty much linear: If pageviews double, just double the size of your Linode.

Disclaimer: I don't work for Linode.


Update (~2 years later) since you want to cache parts of a page with PHP, here's a simple solution that I use that's surprisingly fast. I'm caching several separate parts/portions per page within 1/100th of a second. Seems like a ramdisk could make this even faster but it's plenty fast for my needs:

$cache_file = "./cache/portion-1". $since; // maybe round() this $since timestamp
$cache_life = 1000; // seconds to keep this cached
$filemtime = filemtime($cache_file);  // returns FALSE if file does not exist
if (!$filemtime or (time() - $filemtime >= $cache_life)) {

    // heavy lifting starts
    $output = 'Heavy!';
    // heavy lifting ends

    if (!file_put_contents($cache_file,$output,LOCK_EX)) { echo 'error'; } // save the cache    
    echo $output;

} else { 

    // load from cache
    $output = file_get_contents($cache_file); 
    echo $output;        
} 
0

There are ultimately 3 things that slow down WordPress at scale, and they boil down to this:

  • Hosting stack - you need a good host with the latest software - PHP 7, Nginx, Varnish, Redis, fail2ban and PerconaDB are all good choices
  • No table scans - many plugins are written by amateur coders who do not even know what a table scan is. Two things are needed to avoid table scans - a usable index and a query written in such a way that it can use the index
  • No or few SQL queries inside PHP loops - some plugin code has clearly only been tested on tiny sites, and for one reason or another will loop through every product in your database and make a fresh SQL call for each product/post. You ideally want fewer than 100 SQL queries per page - sounds like a lot, but it's not really and with < 100 you will get a TTFB of circa 200ms uncached.

Once you have the above in place, you can then add caching - e.g. Varnish, CDNs, page caching etc.

If you need to scale out, you can create a cluster using PerconaDB XtraDB for the database and Unison for the files. That way, you can have 1 node as your wp-admin and cron runner, and the other nodes serving web traffic behind a load balancer.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.