Scaling your hosting environment with free services

There comes a point in life when your current hosting environment needs to scale up, and quickly. It might just be that one of your clients gets very popular very quickly, or the gradual adding of sites and resources starts to make services fail. Thankfully there are a few tricks to make life a little bit easier. The less services you can run on your VPS, the more of that precious RAM can get put back into mySQL/Apache etc.

Free Domain based email (
By ‘Domain based email’ I’m referring to sending mail as – and not having your webserver or mail client send it ‘on behalf of’, which I think doesn’t look massively professional (and indeed, is a lot more likely to set off the spam filters). Up until a year or two ago, I’d use Google Apps – annoyingly they’ve cut off their free tier; so now the only really free alternative is – see – you can do IMAP mail too, so it’s a very useful service. Saves you running your own mail service!

Free Transactional email with Mandrill (
Speaking of sending email via your webserver – ever had mail from your webserver go into people’s junk mail? Ever had your server blacklisted for sending too much mail? Or just been rate limited by Google et al? These are fairly common complaints when running your own VPS: I’ve recently setup Mandrill to deal with all my server-side mail – so far I must say I’m rather impressed. There’s two main ways to do this – either setup your app itself (be it WordPress/Drupal etc) or make your server’s MTA (such as sendmail/postfix) send via the Mandrill SMTP service (or indeed via the Mandrill API directly from your code). Mandrill is free for the first 12,000 mails per month, which will probably be enough for most people I’d wager.

Free Email Troubleshooting (
This is a stupidly useful tool for checking all things email related, actually, domain related too – try the domain health tool, should hopefully flag up any issues (although some of the warnings are a little strict).

Free AntiSpam service (
It’s not flawless, but if you run a low traffic blog (sub 50 legit posts a day) it’s better than nothing. Has the requisite Drupal/Wordpress modules too.

Free CDN and DNS from CloudFlare (
This is a bit of a no brainer if you’re not using SSL – change your nameservers over to cloudflare, and you can take advantage of some basic threat management, and a free automatic CDN for static assets (not HTML). Just remember to install the apache/wordpress/drupal plugin to get the referring IP address back from CloudFlare – this is a reverse proxy, so if you don’t understand the implications, do a bit of reading first. You get some (very) basic analytics too, which leads me to..

Free webstats via Google Analytics (
OK, so Google Analytics has been around for ever, and although Google probably uses your data for everything, it’s still a very useful service indeed. Stats, stats and more stats. Saves you running a serverside stats package (unless of course, you need to track things like direct access PDF downloads – although there are some tricks via URL rewriting which can get around that).

Free Web page testing (
This is really useful when you’ve setup a site on cloudflare, and you want to test the reverse proxy – but just generally, it’s one of the best site insight tools I’ve seen in terms of loading of assets, working out where they’re coming from etc.

So it’s amazing what you can get for nothing these days: naturally, all these services have their limitations – i.e, 12k emails a day from Mandrill, no SSL for the free version of CloudFlare, etc, but for a lot of websites out there this won’t be an issue.

What a difference a new server can make

Every now and then, it’s good to have a clean out huh.. 2-3 seconds response time (!) down to 200ms. Not quite sure what happened with that old box, but hey. Fresh installs FTW.

VPS Hosting revisited

So two years ago I started up a linode – yep, I’m still with them for my LAMP stack stuff. I really have no complaints, whatsoever. Since being with them they’ve bumped up my storage to 48GB from 40GB (for free), I’ve had one network problem (which affected everyone in my datacentre) about 18 months ago, but apart from that – nada. zip. Not had to contact support, performance from the VPS itself has been excellent. Awesome.

So now it’s time for me to re-evaluate my other box which is running Railo (and everything else under the sun). This one, running Centos5 is feeling fairly long in the tooth. One of the reasons I’m looking round for a new VPS provider for Railo is that for some reason, Railo has decided to start being slow – like, instead of the usual 500ms response time average, that average has slipped to 2-3 seconds. However, as a) it’s an unmanaged VPS and b) even if I contacted my VPS support they wouldn’t really have a clue about JVM tuning, I’m a little out of luck, bar reinstalling Railo/Java and hoping for the best.

As hosting Java is a smidge more complex than your average PHP hosting, (well, different anyway) ‘Googling’ it doesn’t alway help much.

So, I’ve decided to try Viviotech. Several things have lead me here: 1) very, very good reports from the CF community generally 2) my pre-sales questions were answered so stupidly comprehensively by Jordan Michaels, including appropriate linux distros and future plans for load balancing 3) the price is about right – not worryingly cheap, but not stupidly expensive either and 4) Jordan actually wrote the Railo installer, plus he’s actually answered my questions in the past on the Railo Google Group, which gives me some faith in the support structure.

I ordered it at 9am UK time: within 10 minutes I got a call from Viviotech (from the US, to my UK mobile!) checking/confirming the order. It must have been 1am their time (!). Once all confirmed, off they went. It did take them a day to setup, but I wasn’t in much of a rush, so no problem there. Once all the details arrived, it was just a matter of logging in.

Some nice things they do out the box – move SSH to a non-standard port, add an anti-brute force hack script, setup backups, configure some basic firewall stuff and install vsftp (which personally I don’t use, as sftp should be a minimum). I  asked for Railo to be installed as I was feeling lazy: the only thing which caught me by surprise was Railo running as root – on querying this, they do it for usability, and pointed me to a simple script to change the user Railo runs as. All the Tomcat/Apache connectors were setup and working too.

So so far all very good – there’s something nice in not being *completely* on your own like with fully unmanaged solutions such as Linode. The only thing I miss is those lovely graphs you get in the Linode dashboard (oh and that iPhone app which is amazing) – still I guess there’s always Munin.

You can find out more about Viviotech here

Linode Vs the signup.

I’ve been on a quest for a new VPS, specifically, I wanted something for a LAMP stack – on top of all my CF sites, I’ve got Drupal/Wordpress/PHPBB3 to host as well.

After a bit of research, I narrowed my choices down to Linode and I also wanted a XEN based VM, as I’ve already got a Virtuozzo VM; there’s one thing which scares me a bit about a virtuozzo based vm, and that’s the lack of swap. Whilst the counter claim is that swap is slow compared to actual RAM, virtuozzo based containers give you no leeway there – they just seem to run into out of memory errors.


Linode offer a 7 day money back offer, so I thought I’d give them a try.

The signup process was easy, but when I tried to actually create my disk images and build my distro, I just got ‘Create Disk Failed’. Pleasingly, an IRC client hooked into the Linode channel is built into the admin interface.

I went on an said ‘eh? just signed up but..’ Another customer told me to raise a ticket, which I did. I wasn’t really expecting much, I’d sort of resigned myself to the fact that I was in for some pain and a least 4 hours wait.

4 minutes later, it was fixed, with an apology – they’d simply migrated my linode to a new host, and off I went. 4 minutes for a fix is insanely fast (amusingly, my incredulation was met with ‘Oh year, Peter is a ticket ninja – 4 minutes is kinda slow for him..’ on IRC.)

The interface works well. I’ve already trashed 5 Ubuntu servers, and a couple of Centos ones for good measure, just to try out the preconfigured ‘stack scripts’ they’ve got – i.e Hardened PHP & LAMP stack etc..There’s user generated ones too.

So I was up and running pretty much instantly.

I think my only complaint so far (and it’s not *really* a complaint) is I couldn’t quite get the Stackscript with LAMP stack and firewalling going properly (although this is probably more a reflection on my linux skills than the script), so it meant some manual IPTABLES config. Firewalling is one of those things I prefer to do via GUI (I know, I know, get some CommandlineFu already) in VZ, your firewall is essentially forwarded, so you can configure it outside the VPS, which is a nice trick.

Running a small test via loadimpact had a heavily loaded Drupal site coming in at 800ms for 50 concurrent users, which isn’t bad. By comparison, the current shared host that site is on, the tests wouldn’t go above 30 concurrent users, as it had gone from 1.5 seconds (10 users) to greater than 14 seconds (20 concurrent). No match really. But then, that’s expected. RAM idled around 245MB during the test, with a CPU over 4 cores not really exceeding about 20%. All that’s with out of the box apache/mySQL, no real tuning at all.

I’d had a fairly good response to twitter queries from @vpsnet, and thought they might be worth a try, as I really like the concept of scalable expandable hosting (i.e adding a node).

The signup process was fine at the start, once I got to a computer where the site didn’t think I was in the States. Sorry guys, but the University of Oxford is *not* in the US: either way, not having a way of switching currency or setting your region is bad. So at home, I managed to actually get billed in GBP and signed up.

Instantly, my account was flagged as being ‘held for validation’. 13 hours later, after a ranting tweet, it was magically approved. Still, that’s potentially a lot of time wasted right there. I’d even submitted a ticket, where it was still open 14 hours later, with ‘Private Staff Comment’ as the last response. That’s sort of annoying too.

Then, trying to pay the initial invoice, neither my CC nor PayPal work. Their signup/payment/check process apparently does a micro transaction first, followed by the larger amount; this triggered my bank’s anti fraud measures. I tried two cards, (and also paypal, but of course, this was linked to my card..) and managed to trigger the anti fraud measures on both of them.

After all that, I sort of lost the will, so frankly, deleted my account (not paid anything, or even tried anything after all by this point).

Maybe one day I’ll try again. I will note, that @vpsnet were helpful on Twitter, and I even got a phone message from the states checking on my progress (!), although by that point I’d sort of given up, so I think there is some genuine promise in their customer support.

Oh well, maybe another day.

I ended up keeping the Linode VPS, and am now addicted to looking at CPU/RAM/IO graphs. Sad huh. Oh, and htop – that’s addictive too.

And lastly, a shameless referal link for linode. Go on, you know you want to.

Now Fully on Railo!

Well, I’ve finally moved everything over to my Railo  VPS, including this blog & website, and all the various sites I host. It’s been surprisingly easy – the biggest challenge has been getting the necessary Linux admin skills, and the initial install of Railo/Tomcat.

Things I’m loving about the move so far:

  • Being on Apache / Centos – if nothing else, this has made the whole enterprise worthwhile; my previous hosting, as good as it was, was simply far too limited in terms of space, bandwidth, and most importantly flexibility. Apache give me .htaccess & virtual hosting, whereas before, I was using ISAPI rewrite, which just doesn’t compare (at least in it’s v2, v3 is substantially better). Disk space and bandwidth on Windows servers is just more expensive per MB, most likely due to licensing costs.
  • Railo – the access to a server / web admin combo is a massive step up from standard CF shared hosting: the ability to have shared mappings (think frameworks, shared customtags, shared error handling, shared CFCs) alone has saved me hours of work
  • Slight ‘smug factor’ of running completely free open source software (and submitting bugs to the Railo queue!).

I’ve also moved this blog over Mango Blog from BlogCFC (sorry Ray!), for a couple of reasons:

  • the lack of an update feature in BlogCFC was killing me – having to redo all the theming every time there was an update was just the straw that broke the camel’s back;
  • themeing in Mango Blog is insanely simple, so simple, the theme I’m using here I decided to release to the wider Mango Blog community (it’s available in the Mango Blog admin as ‘OxAlto Capita’)
  • for speed, I really do like having a Rich Text Editor.

The less good:

  • Well, everyone hits a linux permissions issue at least once, don’t they?
  • Managing to delete the root account on my MySQL install – that was less than clever. At least now I know how to boot mySQL in safe mode and fix it.
  • trying to persuade ntp to use a certain UK server pool

Railo / Apache / Tomcat / Mura CMS/ SES URL Gotcha

Another catchy title 🙂

I’ve been trying for a day or two to get SES Urls working on Tomcat/Railo/Apache/Mura;

Specifically, I’m thinking of the /index.cfm/something/ style syntax. Having installed Mura, I couldn’t get any of the actual pages past the front page to work. I got an Apache 404 error.

Sean Corfield’s Blog gave me a good starting point.

As I’d installed Railo via the Beta install script, my config was a little different to some which is what gave me the headache.

Firstly, I had to get Tomcat to receive the requests, as Apache was serving me the 404s;

In my Apache httpd.conf file, I had the following at the bottom:

JkMount /*.cfm ajp13
JkMount /*.cfc ajp13
JkMount /*.do ajp13
JkMount /*.jsp ajp13
JkMount /*.cfchart ajp13
JkMountCopy all
JkLogFile /var/log/httpd/mod_jk.log

Note, the *.cfm entry – this needs changing to:

JkMount /*.cfm* ajp13

This means apache matched the correct syntax to pass the request to Tomcat.

So at that point, I was getting 404’s served by Tomcat rather than Apache; at least they were getting to the correct place.

For me, my Tomcat install lives in /opt/railo/tomcat/, so I found the web.xml file in /opt/railo/tomcat/conf/ and changed added a servlet mapping:

CFMLServlet /index.cfm/*

And then tried again with Mura. No joy – still 404’s in Tomcat; Having re-read Sean’s entry, it turns out you have to specify if you want the pattern to match a directory;

So the servlet mapping I’d put up would match /index.cfm/*, but not, as Mura users know, the default Mura behaviour of /default/index.cfm/*

Changing to:

CFMLServlet /default/index.cfm/*

Sorts it.

I know there’s a jar file supplied by Mura to fix this – but with my seemingly different Tomcat config, I could work out how to get it working properly.

Next stage is going to have to be to get the URL rewriting working to get proper URLs like /about-us/, rather than /default/index.cfm/about-us/.

In at the deep end – getting a VPS

Well, after some research, I’ve decided to go and take the plunge and get a basic VPS.

My aim is to get Railo/Resin/Apache/PHP/MySQL running on Centos 5.3.

I’ve gone for Wizz VPS, as they’re UK based, and a child company of my current PHP hosting – Layershift, with whom I’ve had good experiences – they are also staggeringly cheap.

They’re also completely unmanaged, so I’m on my own…

Getting mySQL and PHP installed was easy, just using the VPS containers package management system (so a bit of point and click). Installing yum and then using that was equally easy. ‘yum update’ = genius.

I’ve been fairly taken back by just *how* efficiently RAM seems to be handled under Linux/Centos. I’m used to a windows box, where just running the OS and CF8 can take up the best part of a GB. I’ve currently got MySQL and PHP, and the OS running under 40MB (not under any load of course) which is amazing.

The tricky part is going to be getting Railo in and running. Whilst there seems to be a fair amount of chat on the Railo Google group about creating some definitive install guides, I’m finding the lack of a definitive install guide somewhat frustrating. I’ve managed to do some things, like install Java for compiling connectors etc, but the syntax (and really, the true understanding of what I’m trying to achieve) does escape me a bit at the moment. My Linux Kung-Fu needs work.

Hopefully we should start seeing some proper documentation for Railo production environments soon! (and I mean documentation for the latest Railo version, and the latest and greatest Linux distros).

Finally – some Railo VPS goodness

I think I’m slightly over the top happy that I’ve got Railo working now..

All thanks to Jordan Michaels’s beta installer (get on the Google Railo Beta list to get access – which worked perfectly.

Had a couple of hiccups, but they were completely my own fault – I was getting a 503 error whenever I tried to serve a .cfm page; checked the logs, and low and behold TomCat couldn’t start: something was using port 8080. (A Address already in use:8080 error)

A quick “netstat -anp | grep 8080” command, and lo and behold, I’d set Apache to listen on 8080 in the http.conf.

Took that out, and restart apache/railo, and all is happy.

Now I’ve just got to read up on Railo security, and pop a bit more RAM In the VPS (it sits at about 140MB with railo/mysql/tomcat and the OS), oh and test *everything*.

As Hannibal would say – “I love it when a plan comes together” 🙂