Minimum Xen VPS for LAMP (osCommerce/WordPress) at XenSmart

October 25th, 2009 | by Sean |
XenSmart Unmanaged Xen VPS in the UK

XenSmart Unmanaged Xen VPS in the UK

First a confession – I tried to ‘go stingy’ and put Lolyco.com on a XS-128 (128MB RAM) VPS at XenSmart, and it really didn’t work. It was initially OK, but after a few visitors, it had filled up both the 128MB RAM and the 128MB swap, and PHP was failing to connect to the MySQL database. The VPS doesn’t have anything of great consequence on it besides LAMP – just sendmail, dovecot, awstats and some bits and bobs.

128MB sounds like a lot to me – I started programming on a ZX81! It has to be remembered that the XenSmart VPSes have 64bit OSes on, so things are a bit ‘fat’ in memory. Also, contemporary software expects contemporary resources, so default configs can be fat too. From watching the ‘top’ utility, it seemed obvious that apache was the main culprit, and its error logs also contained many, many errors:

WordPress database error MySQL server has gone away for query SELECT

And the more obvious:

[error] (12)Cannot allocate memory: fork: Unable to fork new process

No prizes for guessing what’s wrong! Editing the apache2 config to reduce the numbers of StartServers, MinSpareServers, MaxSpareServers and MaxClients did seem to help, but memory usage never really seemed to drop much below 120MB, according to top. Often, the Mem line would say something like 2,000k free (2MB!), while swap would be at 40MB+, and cached often dropped as low as 10MB. The Cpu(s) line would show a large proportion of time spent in Wait, so I’m guessing that it was swapping like crazy. Web pages would take minutes to load – clearly not good enough.

XenSmart are great! When they say “unmanaged” they really mean it. I couldn’t find anything on their website that indicated I could easily upgrade a running VPS. In fact, there’s hardly anything at all on their website. I don’t want this to sound like criticism, because everything XenSmart has promised so far has been delivered, on time, on spec, with no hassles at all. In response to my question, I was told just click ‘upgrade package’ from my ‘products and services’, pay, reboot and I’d get new resources. I had to ask again to make sure the ‘new resources’ wouldn’t be a  reset VPS, but they assured me my data would be preserved.

I paid for the XS-256 (256MB RAM, 256 swap, plus some extra disk and transfer), paid, got all my notices pretty much instantly, and rebooted. It was 80 seconds (I was watching the ping output – I miss having an console to watch with a VPS!) before I could log back in again, and it appears to be very responsive. Time will tell, I guess. It does seem as though the ‘number of Servers’ settings in apache2.conf is key to keeping LAMP running in 256MB. I’d be interested to know what experience others have with LAMP on small VPSes.

PS – While I was looking for some links to add to this article I came across this HowToForge article:

http://www.howtoforge.com/configuring_apache_for_maximum_performance

It advocates setting MaxClients to total RAM / Max process size. On my 64bit Xen VPS, I can see several apache2 processes at 27MB! It does seem like avoiding swapping at all costs is the key.

Post a Comment