Friday, 11 May 2012

Channel API

Google App Engine is a web hosting service that allows you to write server software in Java, Python or Go. Overall I think it's a great piece of technology that really helps the programmer get into the mind set of writing scalable services, it was also a cool way for me to finally learn Python. Anyway I'm currently interested in the suitability of it for realtime applications like games.

The traditional web model is a request/response based model. The client requests a resource from the server, the server does some processing and returns the resource. That's the end of the transaction. In this model there is no way for the server to update the client without first receiving a request from that client. If you want to build a multiplayer game then this is likely to be very important.

It can be simulated either by regular polling from the client (does not scale well), by some fairly hacky techniques falling under the umbrella of Comet, or by the new WebSockets technology available recently. Google App Engine does not support WebSockets, but it does support Comet under the guise of the Channel API.

Test App here!

I was interested in the performance of the Channel API so I wrote a small test app. I'm a bit of a noob when it comes to Python and HTML/Javascript but if you want to take a look I uploaded my code here.

Overall I was disappointed with the results, and indicates to me that if you want any kind of fast response game then you may have to look elsewhere.
  • Very unpredictable latency (200-1000ms)
  • Big packet overhead of HTTP headers etc
  • No peer to peer support at all (limitation of current web technologies)
  • No support for broadcast messages (server must send to each client in separate call)
  • Sending several messages at once can result in a massive increase in latency

That said I do think the technology is quite promising and certainly opens up the possibility of doing whole classes of games with two way communication. Strategy games, or other games where one player does not directly affect another. Adding chat for instance is a perfect use case for this. If you are thinking about using Channel then I found out a few things that might be useful to you.
  • Reliable - in all my tests all messages eventually arrived
  • Out of order - messages are not guaranteed to be in sequence so if this is important you need to handle your own sequence checks
  • Multiple instances - don't forget the service may spin up multiple instances to handle the requests
  • Development server is much worse than the live server (on Windows at least)! It seems to serialize all messages sent with approximately 600ms between each one.
If anyone has any insights into the poor performance (maybe the server setup is wrong for instance) I would love to hear from you. If anyone from other parts of the world could test and report back your average latency that would be awesome!

Cross posted to AltDevBlogADay which has some great comments.

TortoiseGit and Google Code

As a Windows user I recently struggled to figure out how to make TortoiseGit push my local code to a remote Google Code repository. Google Code gave me a password to use but the client never asked me for it. If you are having the same problem here's how to fix it!

The short answer is to add the password Google gives you to the URL using something like this https://name:password@path_to_repo/

Create your project on Google Code or find the Git hosted project you want to commit to. Go to the Source tab and grab the clone URL (you have to be signed in to get this). Navigate to your local folder you want to hold the repository and clone it through TortoiseGit the normal way.

Once you have cloned it navigate to the directory, right-click and choose TortoiseGit -> Settings
Select Git on the left hand side.
Select Edit local .git/config

This opens up a config file. Look for the URL line that looks something like this

url =

Get your GoogleCode password from here and paste it in so the line looks something like

url =

If all goes well when you Push you should see something like this!