Minimalist WordPress Deployment

So, my “sugar daddy” datacenter is kicking me out. This is where I have been hosting absolutely free for a decade so I have nothing bad to say about them… at all. :-)

My 4U quad-core2duo, 4GB RAM, 8TB SATA beast will soon become homeless…. Did I mention they let me host that monster for free?

This website was a minor task for that server but last Sunday I moved it onto a minuscule “cloud” VPS at Gelsys. Running PHP and MySQL on 256MB of RAM (and no swap) and expecting a stable server under load did require some tinkering. I am not going to detail every little thing. I’ll only outline the basic setup.

I have WordPress spitting out static html files which is what is being served for 99% of all requests. PHP is only being called on to re-generate the files when the caches expire and to serve up the admin interface. In this way my mini-VPS can handle a pretty decent amount of traffic. I don’t generally get a lot of traffic but I am curious to see how the server behaves during a spike.

WordPress caching is handled by the excellent W3 Total Cache plugin which recently got official support for Nginx. Yay! no more custom rewrite rules. My only problem getting it running this time was that it refused to cache the index page, which is kind-of bad when it is one of the heaviest pages to render. Turned out it was a simple precedence issue. “/” is considered a folder which I caught in a rule before the caching rules had a chance to do their thing.

Nginx is the web server. I have been running it for a few years already but for this it is absolutely essential to save on ram and get the best performance serving static files.

PHP is called from Nginx over an unix socket and served by php-fpm. PHP is compiled with my favorite accelerator eaccelerator. It is just the simplest to get going and has shown good performance for my apps. PHP has been scaled down a lot in php.ini, reducing mainly memory usage and timeouts.

MySQL loves memory so I had to do the equivalent here. Basically taking the standard performance tips and doing the opposite. I know I will only server WordPress and I know I don’t have any enormous datasets so MySQl should be fine on very low memory. Also since I limit the number of php processes I consequently limit the maximum number of client connections MySQL will need to keep track of.

The only other service running is ssh and I was surprised to find that sftp was one of the biggest memory hogs. Uploading a bunch of files of sftp and the server would immediately come dangerously close to running our of memory. In fact it did a bunch of times during my tweaking.

I have been thinking about switching from WordPress to some static website generator but that is for another time. This setup looks fairly smooth at the moment.

Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Twitter
  • Google Bookmarks
  • email
  • Technorati

Comments

2 Comments so far. Leave a comment below.
  1. Martin,
    I love the Basic Maths theme, but when I tried it out on my site, along with SuperCache, I noticed that a browser might be handed a file that had been generated for another browser. For example, if the first person to view page X used a Chrome browser, then SuperCache would save an html file that had a body class for Chrome. Hence, if the next person to view page X used IE, he/she would be seeing a page that was intended for Chrome users. (I used the static page generation of SuperCache since it is the fastest.)

    I’ve noticed that you do not appear to have such a problem using Total Cache … are you using the php-caching mode instead of static caching?

    I have tried getting Total Cache to work on my shared server (with Tiger Technologies), but it keeps kicking my butt … it seems to require more knowledge than I have, as far as getting it to work right, especially on a shared server.

    Any thoughts? I’m very tempted to go back to Basic Maths. My traffic is less than a 1,000 hits per day, so I could probably even do without caching.

    Best regards
    Bruce Keener

    • Hm… I had not noticed that BasicMaths does that. Generating body classes in php sounds like kind-of a bad idea, I am surprised they wound do that. I don’t really prefer body classing but have done that using javascript from time to time.

      Looking at my pages in Firefox, Safari and curl I see the same body classes applied… the Safari ones since that page was the one to be rendered to the cache. I do not cache the index page statically… only the individual articles… and the cache-time is low. I guess this is why the problem is less apparent.

      Did you ask Koi about this? I think I will at least email him and mention it since it affects most forms of page caching.

Add Your Comments

Disclaimer
Your email is never published nor shared.
Required
Required
Tips

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <ol> <ul> <li> <strong>

Ready?