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

October 25th, 2009
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.

IE8 Cookie problem

October 8th, 2009

It’s 3am, so this will be brief. Firefox, Opera and Google Chrome are all happily accepting HTTP cookies from wossis.com, but IE8 was gaily ignoring them. The problem is speech / quotation marks in the Set-Cookie line:

Set-Cookie: MIFS=”qVZziOA7″; Path=”/”

…works in 3 out of 4 browsers. IE8 pretends it never saw it.

Remove the quotation marks:

Set-Cookie: MIFS=ngv_Aesy; Path=/

…and IE8 will recognise it. I do vaguely remember reading in RFC2109, the bit about:

10.1.3 Punctuation

In Netscape’s original proposal, the values in attribute-value pairs did not accept “-quoted strings. Origin servers should be cautious about sending values that require quotes unless they know the receiving user agent understands them (i.e., “new” cookies).

…but was still surprised (for hours!) that IE8 wasn’t accepting a cookie that was acceptable to the other browsers. If this problem crops up for you, I hope you read this well before 3am.

Wossis? Flashcards, that’s what!

September 26th, 2009
Wossis? Flashcards!

Wossis? Flashcards!

I turned the flashcard page I wrote at poditronic.com a while ago into a site that allows its users to add their own sets of flashcards. It’s at http://wossis.com/ if you’d like to see it. It’s still very early days, but things are now stable enough to tell people about it – I think!

I’d appreciate it if you’d use it, make some flashcards for it, and tell me what you think. Emily, my daugher whose kindergarten flashcards gave me the idea, likes it. I’d love to hear what any 3-year-old experts in your house have to say!

That’s all for now – there’s a lot of flashcard creation work to do!

Correct response for wrong Host: field in HTTP request header

September 25th, 2009

Still frantically trying to get Spinneret into shape for a first open-source release. I’m also working on a new project that I’m quite excited about, which is providing plenty of examples of where Spinneret could be improved!

The new project is hosted on a VPS at VPSLink (recommended, so far!). Today’s curve ball was Google’s googlebot requesting pages that belonged to the previous owner of the IP address. I could see the previous domain name in the debug output in the ‘Host:’ request header field. Almost every request from the googlebot was causing my server to return a 404 – the URLs were all from the previous domain’s site.

In the interests of not cluttering up search indexes with my content duplicated for an expired domain, I decided that my new site should just plain reject requests for other hosts identified in the Host: header. I couldn’t decide which 4XX error it should be, but finally I decided to send the 403 (Forbidden) status code, with an explanation that the Host: header field was what caused the problem.

A quick search turned up nothing – I could annoy some admins by using cURL to send some wrong Host: fields to various sites, but I don’t really have the time. I’d be delighted if anyone could upgrade my ignorance!

Streamyx email client setup: TM’s configuration out of date?

September 19th, 2009

While testing a Java-based mail server I’ve been working on, I noticed I could no longer send email from my Streamyx email account. I never use it, except for testing, or to delete the spam that builds up from TM Net, so it has been a while.

TM’s ‘Setting Up SMTP Proxy for Email Client‘ page seems to be out of date. They use a dummy email address in all but one of the pictures on the page, where you can see a ‘jennyATstreamyx.com’. I have to login to webmail.tm.net.my using ‘username@streamyx.com’, but it wouldn’t work with my email client. I couldn’t send out an email from Thunderbird using my Streamyx username ‘@streamyx.com’. To successfully use smtp-proxy.tm.net.my, I have to send mail from ‘username@tm.net.my’. Here’s a telnet session using the same username, but different domains, in the MAIL command at smtp-proxy.tm.net.my:

Streamyx SMTP Proxy needs 'tm.net.my' email address

Streamyx SMTP Proxy needs 'tm.net.my' email address

I hope that’s useful for someone!