Google Web Engine API Channel vs. Node.js+Socket.io (comparing performance)





0/5 (0 vote)
Comparing performance channel api and socket.io on example of multiuser whiteboard
Introduction
My purpose is to implement a mutliuser shared whiteboard for my university project. Such a type of application needs to communicate extensively with the server, so AJAX is not fast enough.
The possibilities which I have found on the web were:
- Google App Engine Channel API (https://developers.google.com/appengine/docs/python/channel/overview)
- Node.js+socket.io (http://socket.io/)
This small article is going to be about comparing the performance of Channel API and Node.js+socket.io
Using the code
I am not going to explain how the code is working, as it's pretty much explained in the Resources which I have used (see below).
If you would like to run the Google app engine implementation you would have to use the Google app engine (see their documentation here: https://developers.google.com/appengine/docs/python/gettingstartedpython27/)
If you would like to run the node.js+socket.io implementation, you would need to use some hosting for it. I used free amazon's hosting for that (here is the explanation on how to configure your amazon instance for using node.js http://iconof.com/blog/how-to-install-setup-node-js-on-amazon-aws-ec2-complete-guide/)
The source code is attached to the article in zip archives.
Conclusion
So, the code which I wrote for the Python+Channel API (hosted on google app engine) is almost the same as the one which I wrote for Node.js+socket.io (hosten on Amazon micro instance), but performance of socket.io is better than performance Channel API. I suppose the reasons for that are the following:
- Channel API supports only server->client communication. To send messages from client to server I had to use usual http requests through ajax. Meanwhile, socket.io supports two-way communication.
- Channel API doesn't support broadcasting of messages (sending them to all clients). So I had to track current connected clients and send them the messages.
It seems that if you send many messages through Channel API they don't always arrive in the order in which they hsd been generated. I am not sure about that, but the code, which I wrote using Channel API behaves a little bit buggy: instead of ending a line and starting a new line, it can connect the end of the first line with the beginning of the second line (this can happen especially if you draw quickly). Although, I don't have that problem with that same code while using socket.io.
Here is the link to demostration of the application's performance: http://youtu.be/sI1hb-ybb5w
As you will see, my the application is pretty slow and there is a lot to be done, but it's enough for comparison of Channel API and socket.io.
Resources used
- http://wesbos.com/html5-canvas-websockets-nodejs/ Explanation on how to implement the multiuser whiteboard using node.js+socket.io
- http://blog.greweb.fr/2012/03/30-minutes-to-make-a-multi-user-real-time-paint-with-play-2-framework-canvas-and-websocket/ I mostly used this code/logic for my project, but used different code for my server side.