Saturday, June 22, 2013

Embracing for an overload ... or how to load balance your web server

Almost all mobile games somehow now use a web server. Even if you are using facebook for the social part and friends leaderboards, facebook's leaderboards API is very limiting (at least at the time of writing you cannot have multiple leaderboards for a game for example). So developers tend to roll their own leaderboard system that spams facebook.

But what if your web server used by your game does not hold up the initial rush of users?

Your server gets crushed by the load of users hitting your server. You can set up multiple servers to prepare yourself, but that can be costly especially when you don't know how many users are going to be playing your game.
Ideally you dynamically add/remove web servers depending on the load, so you save costs.

Enter heroku + +

Heroku is a hosting service that supports multiple server doesn't scale them automatically. Originally it started with ruby on rails but now supports other languages like php (1 server is free, 2 servers is 30$/month, 4 servers is 200$/month, 100 servers around 2000$/month at the time of writing, etc). It uses git underneath, and it makes it really easy to push and release updates. Facebook are also collaborating with heroku for easily creating a web app hooked up with facebook. is for doing stress testing (awesome and free) monitors your web app every minute or so, and it auto scales up/down your number of web servers depending on your load. (Will cost you around 10$/month). It's really cool seeing this little app communicating with heroku to scale up/down your servers almost instantly (1min is not a long interval).

They are very easy to set up. I am using them for preparing for the launch of That Monsters Game, which will be available for download July 18th.


Gerard said...

I love the game and how smooth it is!. Congrats!. What unity input system did you use?

xenon said...

Hi Gerard,
I used NGUI for the UI, but for the tracing monsters it is just a manual raycast and checking if I hit a monster or not.

Are you developing a game in Unity as well?