jbillmann / GarageServer.IO

A simple, lightweight, HTML multiplayer game server (and client) for Node.js
MIT License
181 stars 29 forks source link

Consider using msgpack for socket messages #22

Open maritz opened 9 years ago

maritz commented 9 years ago

https://www.github.com/msgpack/msgpack reduces the size of the transmitted websocket frames and thus should help keep bandwidth down.

dirkk0 commented 9 years ago

Additionally/alternatively this article shows a number of ideas on how to optimize: http://buildnewgames.com/optimizing-websockets-bandwidth/

jbillmann commented 9 years ago

@maritz @dirkk0 I've thought about this quite a bit and I'm struggling to justify having GarageServer.IO manage compression.

Let's say for a moment that GarageServer.IO would manage compression, after you consider packet gains and cost of performance, I think that compression, and certain types of compression are not for everyone.

With respect to MessagePack, for example, consider the first couple of comments in each of these HN threads:

https://news.ycombinator.com/item?id=4091051 https://news.ycombinator.com/item?id=4093077

In a nutshell, MsgPack isn't always faster when considering JSON and a browser, but of course, it always depends on the situation.

Perhaps a better route is to expose call backs (encode, decode) that provide the data which will be sent such that developers, if they so choose, can add in their own compression, consume compression libraries, etc.?

maritz commented 9 years ago

Yes, sounds great.