Driving the (ve) Server at Media Temple

It’s been a few weeks now since Media Temple launched their new (ve) Server and I’ve been testing it out for a few days now. I’m actually hosting my blog there to experience some real traffic load and my first impressions are awesome!

I started off with the simplest 512 MB server and transferred a few websites to the new platform. I’m not too used to the Ubuntu Linux operating system but I found my way around quickly. They do have other operating systems options, but Ubuntu is the one they recommend. First few tests showed that my load time decreased dramatically compared to my Amazon EC2 instance, which I was quite happy with. Next step was to run a few load tests using the Apache Benchmark tool (ab), and very soon I realized that I got quite a few failed requests, memory shortage and other strange stuff.

Media Temple’s (ve) servers are hosted on the Virtuozzo platform by Parallels, and after browsing their documentation I found out that there’s no swap space available for Virtuozzo containers. They do allow around 80% of burstable RAM (so you get around 1 GB when running 512 MB) but when that runs out, you’re left with nothing, not even some swap space on your hard drive. Some heavy load tests showed 30% request failure, which is quite horrible.

Media Temple don’t give much information on the new platform via the support system and in memory shortage questions in their user forums they advice you to upgrade, of course! Well, I wouldn’t like to upgrade to just run a couple of load tests, and what about Digg-traffic? Should I predict that and upgrade before the spike? Then downgrade again to save some cash? Of course not.

A good option I found here is to tune Apache a little bit, reduce it’s resources limits. This will not increase performance, but may guarantee a 100% fail-safe workflow. We wouldn’t like our users to see a blank page (or a memory shortage error) when a spike hits, but we would rather want them to wait more than often and still load the requested page. The settings mostly depend on what software you’re running, which services and the RAM available in your container.

You might want to reduce the KeepAliveTimeout in your apache settings (mine’s now set to 5), and the rest is up to the mpm prefork module. You’ll have to modify your settings and then run some tests until you’re comfortable with the results. Mine are the following:

<IfModule mpm_prefork_module>
    StartServers 3
    MinSpareServers 2
    MaxSpareServers 5
    MaxClients 10
    MaxRequestsPerChild 0
</IfModule>

This is on a 512 MB (~ 400 more burstable) container. An Apache Benchmark test showed that 100 concurrent (simultaneous) requests performed in 26 seconds with 0% failed requests, this makes 3.84 requests per second, which is quite good. To give a comparison, the same test ran on the mashable.com website gave 30 seconds with 3.32 requests per second, and of course a 0% failure. Also check out other MPMs for Apache which could give results too.

This definitely requires more fine-tuning and if the page load time becomes too high then yes, there is a reason to upgrade, but don’t forget about other performance tricks such as CDNs, gzip (deflate) and others. When you’re done with Apache, proceed to MySQL fine-tuning & php configuration, there are some tricks there too to give you some extra speed & performance.

I’ll keep playing around with this server, plus I’ve purchased a 1GB (ve) this morning, so there’s quite lot of tests that have to be run. Anyways, if you’re looking for a good, high-performance VPS, then Media Temple is definitely a choice to consider. For only $30/mo you can get quite a good looking virtual server. It is more interesting than their old dedicated virtual servers (although still in beta). Cheers, and don’t forget to retweet this post ;)

Benchmarking: Your Web Hosting is Not That Perfect

Today I realized that the VPS I’m renting for $20/mo is not as good as it seemed at first. Ever thought about high loads? Okay, this may sound like some DDoS hacking tools, but no! 100 requests with 10 simultaneous made my virtual private server think for ~ 1,5 minutes. Jeez!

It took me quite some time to find good software for running some load tests on my webserver, linux has some good utilities (linux.com/feature/143896), but I suggest you start from ApacheBench which is a command line utility bundled with the Apache distribution. It’s cross-platform, therefore you can use it on Windows (I did). Anyways, here’s how you launch a test:

ab -n 100 -c 10 http://www.microsoft.com/

Why did I pick Microsoft? Well, if I get like 10,000 views tomorrow and everybody tries that command, that’d be a DDoS attack on Microsoft servers and I think they’re good enough to handle it. My server would just explode :)

Anyways, take a look at what the results may be like:

Benchmarking www.kovshenin.com (be patient).....done

Server Software:        Apache/2.2.8
Server Hostname:        www.kovshenin.com
Server Port:            80

Document Path:          /
Document Length:        84 bytes

Concurrency Level:      10
Time taken for tests:   90.984 seconds
Complete requests:      100
Failed requests:        1
   (Connect: 0, Receive: 0, Length: 1, Exceptions: 0)
Write errors:           0
Non-2xx responses:      100
Total transferred:      36564 bytes
HTML transferred:       8674 bytes
Requests per second:    1.10 [#/sec] (mean)
Time per request:       9098.438 [ms] (mean)
Time per request:       909.844 [ms] (mean, across all concurrent requests)
Transfer rate:          0.39 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   15   3.4     16      16
Processing:  2203 8866 8879.2   6188   48797
Waiting:     1969 8532 8664.9   5891   48750
Total:       2219 8880 8879.6   6203   48813

Percentage of the requests served within a certain time (ms)
  50%   6203
  66%   7281
  75%   8141
  80%   8313
  90%  17078
  95%  32266
  98%  43813
  99%  48813
 100%  48813 (longest request)

Ah.. And a failed request there, how sad… You might also want to check out your load on the server while benchmarking. Use the ‘top’ command, it should produce similar output:

Yup, although the super cache plugin is working, wordpress consumes a lot of memory… I also ran this with a 500/100 requests, that made my server go down for like 6 minutes, I had over 200 failed requests and my blog kept saying database connection error until the test had finished. Free memory dropped down to 0! Scary? For more information about how ab works, read Apache HTTP server benchmarking tool documentation at apache.org.