30 comments

[ 2.3 ms ] story [ 116 ms ] thread
This fails to mention the most dramatic fix, which is to host it on NGINX rather than Apache.
Not only that, but every time a page load happens. There is a cronjob that gets executed.

You can seperate the cronjob by executing it by duration ( a real cronjob), instead of executing it every page load.

Thank you for mentioning this. I wish people understood this better.
Oh? How big of a difference does that make? I'm not even sure what to measure? I can host 100 WP sites that generate a total of 100000 hits in a day using Apache requires X RAM and X Cores but using NGINX I could do that with only X RAM and R Cores? Did you find something like that? I'd love to squeeze more out of what I have if I can do it with NGNIX.
I don't have specifics like that, but I've noticed drastic improvements in page load time when I moved a site from Apache to NGINX. This post was the motivation:

http://reviewsignal.com/blog/2014/06/25/40-million-hits-a-da...

Oh that's mine :) Glad it was a motivator. There are surely better configs out there now with a lot more resources behind them like easyengine.
Nginx vs properly configured apache makes little difference on for a small-to-medium site. What makes a difference is fastcgi caching, it's an important difference.
Agreed. An overloaded WordPress site with a minimal 5 minute page cache can now handle a HN storm. Throw in a CDN for the static assets, disable commenting, and it could likely handle the front page of Reddit.

Amazing how fast a site becomes when it's no longer recalculating every response.

For commenting you can always use Disqus which would take the load off your database.
WordPress is garbage unless you statically cache the generated html. I haven't been able to keep the servers running on even medium traffic sites doing anything else. It's simply far too slow.

On anything short of a supercomputer you can get about ten requests per second with the stock setup and zero content/plugins. Adding anything to the site just makes that number worse.

My rule has become don't use WordPress for anything but html generation. It's not a serious CMS for anything else

Ever used the WP-API? It is a REST API and you can bypass the native templating system and even the WP admin entirely. There are plenty of people are building web apps with WP/WP-API as the back-end. WordPress is a lot more than it used to be.
Last time I used the API it was incomplete and slow. The "multi request mode" also exposes all sorts of resource exhuastion attacks. I had a ton of sites go down from "bundled" login attempts where they tried something like 100 passwords at once. I usually end up blocking it completely
The Wordpress backend still has scaling issues with many popular plugins. Helping a site with 100,000 customers in a woocommerce database migrate to a more robust ecommerce solution because it takes 15 minutes to log in currently.
I'm curious what does a "medium traffic site" mean? I feel like I have a bunch of what I'd call "medium traffic sites" and I've not had much of a problem with them. Though, maybe my "medium" is actually "small"?

Is there a general rule of thumb for site traffic? Like a "medium traffic site" gets X Hits, or whatever?

100 requests / sec average seems medium traffic to me (and outside the bounds of wordpress live)
8.6 million requests/day is only medium traffic?
Sure. Well let's call it 1 million per day peaking at 100 req/sec... not many websites are steady state 24/7

But this is orders of magnitude below what a Google or Espn or Amazon do. But orders of magnitude over what 1 PHP server can do. (But oddly enough, within the realm of possibility for a good Java or Go or Rust server)

Nonsense.

I just ran a load test against WP yesterday and with a traffic load (from tsung cluster) peaking at 430 req/sec, it was easily served by 5 t2.micros running Varnish + WP (behind Apache no less) + memcached.

The load test included random search strings 50% of the time so half the tsung visitors were getting live service from Wordpress.

For a while I did something similar. I used a private instance of WP to generate my blog content and then scraped the site to get static pages which I could then serve from another machine. That meant nothing dynamic, no WP "vuln of the week" treadmill, and no cache-layer validation headaches either. It worked pretty well. For a larger site I could have made the generation more selective, and (re)optimized the output in many different ways, but it wasn't worth it. Then I got off WP entirely and it was all a moot point, but it's an approach to consider for those stuck in WP-land.
Plenty of sites would like to disagree with you.

Nginx and PHP7.1-FPM will make it quite fast, even on a $5 DO server. Caching will speed it up quite a lot more, but you should always have your pages behind a cache, thats one of the points of a CMS is to generate you html that is stored until modification.

I don't agree that WordPress is as bad as your saying... But the static HTML caching part can be easily achieved, with plugins or with Cloudflare for instance.
Also fails to mention enabling SSL which shortens load times.

This might not be an option for those on free Cloudflare plans, though.

TLS comes with the free Cloudflare plans.
I recently wrote up my Caddy+Varnish+PHP-FPM solution for WordPress[0]. It's fairly complementary to the steps detailed in the OP. The site absolutely flies now: 50-75ms response times cf. 200-300ms per Google, A+ on SSL Labs cf. unencrypted HTTP/1.1, and the $10/mo VPS rarely cracks 1% CPU utilization despite it being a modestly well-trafficked site. Our organic search position has improved significantly.

Caddy was maybe an odd choice but it performs well and it's been a breath of fresh air after dealing with some gnarly NGINX and Apache configurations in the past. So far it's been easy to maintain and there's a clear CDN migration path (Fastly). I'm using Docker's official PHP-FPM images[1] to serve multiple sites with some isolation, sharing Caddy, Varnish, and MariaDB instances.

I'm not sure if this solution has value for anyone else but I've been plugging it here and there in case there is!

0. https://gist.github.com/mwpastore/f42f6f1309a7b067519f4c08e1...

1. https://hub.docker.com/_/php/

have you tested what happens if you substitute in HHVM
I have not. The whole purpose of an architecture like this is to turn WordPress into a glorified static site generator, so it doesn't particularly matter how fast (or slow) the application server is. At any rate, I thought PHP 7 was about as fast as (and even faster than, in some cases) HHVM?
it might be now, which is why i asked if it made a difference. does a page need to be visited once to be added to the cache?
No, not for s-maxage seconds.