Cloud Hosting

09.11.2011

This article is for the indie game developers in our readers. I'm going to share what I've learned over a period of approximately two years about hosting a website for a game. I would have loved to read this about a year ago, it would have saved me a lot of work. Maybe the past me can read it due to a strange time loop phenomenon.

Ever since I released the first alpha of Driftmoon, I had a nagging suspicion about the performance of our website. Will it hold under stress? What if Driftmoon is featured on the front page of a big website, and we get a hundred thousand users all at once? If the website doesn't cope with the load, the publicity would be useless! Thousands of dollars and euros would be lost! Not to mention all the countless individual minds deprived of refreshing themselves in the world of Driftmoon!

That's where I started. I had a virtual PHP server, with Wordpress running the website and phpBB running our forum. The server was barely coping with the current load, with slowdowns every now and then. My first thought was to buy a bigger hosting plan - and doing that would have saved me a lot of time. But the trick here is that I don't know if there will ever be a huge spike of traffic to my website, or even how big a spike! I could buy the costliest hosting plan there is, and still be under capacity when the the game is featured on a big site.

Another point is that since the website will usually run at a very low volume, only to spike out when someone notices us, there's no need to run an expensive service all the time. The costs would quickly outrun any of the money I get from selling the game!

So I started tuning my Wordpress installation. I used every caching trick and plugin I could think of. I spent weeks improving the efficiency, even putting together a simple content delivery network - I offloaded most of the static content like images and files to Amazon Cloudfront. But still I knew if enough users came at once, the main server simply couldn't cope with it.

At that point I was actually thinking of making the whole site out of static webpages. Those would be cheap to host on any server, and they would be extremely fast to server. But in the end I decided that updating the site would be too much work with a static site, besides I needed to have dynamic content like the forums and blog comments.

Then I decided to give cloud hosting a chance. I moved away from my cheap host to the Amazon EC2 cloud where you can get micro instances for cheap. In theory you could make a sort of autobalancing system that would add more virtual hosts as needed, dynamically increasing the power of the website, but also at the same time increasing costs. After trying for about half a year I was still no closer, because configuring all the Linux subsystems by hand was taking more and more time. I decided that I'm a game developer, not a sysadmin, and started looking elsewhere.

In the end I decided to use Google App Engine, because it promises to run a simple site for cheap, and automatically scale upwards when traffic spikes. No Linux administration needed! I wrote a little bit about that earlier, but I didn't want to get too much into the details in case there was still more to learn about it. The jump into App Engine seemed massive, not only was there no useful blog software like Wordpress available, there was no forum software either. But the lure of the cheap and scalable webhosting was too strong.

It actually took the better part of two weeks to rewrite the parts of Wordpress I needed to run on App Engine. And I'm still putting finishing touches to my new forum that I wrote based on phpBB.

And how is App Engine working for us? Extremely well. Right now I pay a flat minimum fee of $9 per month. App Engine has a generous quota of one free server instance, and my well oiled blog engine uses about 1% of that instance at normal (orange line). Sometimes bigger traffic spikes actually fire up more instances that run for a while to service the users - and that costs $0.04/ Hour / instance. But as you can see in the graph, the billed instances stays at about 1 instance, they're practically giving me extra capacity for free.

I won't say there aren't any downsides to using App Engine, such as the need to write your own software because there aren't enough existing ones, or some of the changes they're making to the platform all the time, but it seems to be well suited for our current usage. Whatever your choice is, just keep in mind that your game could be the next Minecraft, and you don't want to be caught with a lousy server when people start flocking to your site. So don't be afraid to spread the word about Driftmoon, this site should now be able to handle millions of users rushing in at once!

Ps. I've actually even given a little thought about possibly releasing our forum software some day, if there's demand for it.

blog comments powered by Disqus