My Journey To Managing My Own WordPress Server

4773457853_b10fcc8294_b

TL;DR — I used to shy away from managing my own server, but with experimentation I got more comfortable with it and now manage my own server.

I wouldn’t call myself a sys admin. Sure I know my way around a Linux box pretty well, but there’s a lot I don’t know. I don’t spend my days managing servers, so I don’t read up on the latest trends and or security news. I know of a few things that I don’t know, but really I’m most afraid of what I don’t know that I don’t know.

When I first setup WP App Store, I didn’t even consider hosting it myself. At the time, Stripe was not available in Canada, so I had to pass credit card information through the app. That meant I needed PCI compliant web hosting. Even more reason to not host it myself!

After bouncing between a few different hosting solutions that I wasn’t happy with, I finally found out that Amazon EC2 could be setup as PCI compliant and so I went to oDesk and hired a sys admin specializing in Amazon Web Services to set it up. I kept him on retainer to monitor the server and keep it up-to-date.

At the same time, I decided to challenge myself and setup an EC2 instance to host this blog. I dug into the server that the sys admin had setup and figured out what he had done, how he had setup the file system (EBS) properly, what scripts he was using to make EC2 snapshot backups, etc. And so I managed to setup a new EC2 instance, very similar to what had been setup for WP App Store: Varnish + Apache + MySQL. (Amazon Web Services actually allows you to use most of its services for a year for free, so it’s a great opportunity to learn.)

Server CablesI installed New Relic monitoring to keep an eye on things. And I did run into a problem. Once every few weeks, Apache would crash and need to be restarted. After some research, I found out that Apache and MySQL had to be tuned for the EC2 micro instance’s low-memory. Once that was done, no other problems. And the tiny amount of CPU and memory was enough for Varnish to serve over 12,000 page views when one of my blog posts made the front page of Hacker News last year.

Shortly after I setup my blog on EC2, I faced the dilemma of choosing a hosting solution for my new ecommerce site, deliciousbrains.com. Since I had just started the experiment of hosting my blog on EC2, I wasn’t ready to host an ecommerce site myself. Stripe had launched in Canada, so the server wouldn’t need to be PCI compliant, but I still wasn’t comfortable with the idea. I decided to try AppFog, a cloud platform-as-a-service (PaaS). Unfortunately each request was very slow. We’re talking upwards of 2 seconds to complete a page request. Just the HTML. I’m not talking about images and other assets. It was brutal. For months I just put up with this all the while asking AppFog for ways to tune performance but they took a very long time to reply (25 days!) and were not helpful.

Then everything came to a head. I had had a conversation with John Turner where he described managing his own servers, how he had optimized his WordPress sites, and how important page request speed is for ecommerce conversion rates. Plus I had been managing my own server for my blog for nearly a year with very little problems. Plus I was very unhappy with AppFog. I felt it was time to manage my own server.

After a bit of research, I found that Linode was a better option than Amazon EC2 and setup a new server on Linode. I really made an effort to learn more about Varnish and setup the config files nicely for multiple web sites. I’m now hosting all my sites (deliciousbrains.com, bradt.ca, wpappstore.com, and bigsnowtinyconf.com) on that server and have been very happy with the results. Most pages are served from Varnish’s cache which consistently comes in at under 200 ms. Varnish is truly incredible. A post from this blog made the front page of Hacker News earlier this month and the server didn’t even break a sweat. Varnish served up the cached page to 10k visitors in 4 hours with no noticeable decrease in performance.

What I’ve realized is that there’s a lot of value in managing my own server. I can tweak things at the server level specifically for my site. Managed WordPress hosts typically bypass the Varnish cache when a cookie is set (they do ignore some cookies, like Google Analytics). So if you’re running a shopping cart on your site, likely every request will bypass Varnish and be processed and served by Apache (much slower). Managing my own server means I can configure Varnish to not cache certain sections of my site, regardless of what cookies are set. I tell it I want everything cached except /my-account/*, /cart/* and /checkout/*.

Sure I’m spending more of my time managing the server. But I think that’s a good thing. I have complete control over its performance. And when you’re talking about ecommerce, this is extremely important.

I’m considering trying my own dedicated hardware next. Codero Smart Servers look very good. Less money for more power. And although I’m skeptical about it, I’d also like to try an Nginx + PHP-FPM configuration. I’ve heard it performs a lot better than Apache + mod_php, but I am concerned that it doesn’t obey the set_time_limit() PHP function, which results in more frequent timeouts. I’ve been seeing a lot of 503 errors out there, so I’m not convinced it’s better than Apache for overall reliability. I’m also considering trying CloudFlare or serving pages through Amazon CloudFront, which should result in another page speed boost. The journey continues!

Do you manage your own server? Would you like to? Would you like me to read more about how to set this up?