6 ms·
Experiments with WebSocket Performance (for HTML5 games)
- paulgb 14y agoWill WebRTC alleviate this at all? Looking over the spec[1] it seems that there is a "reliable" flag on the DataChannel, although the implementation of the underlying transport is not specified. [1] http://dev.w3.org/2011/webrtc/editor/webrtc.html http://dev.w3.org/2011/webrtc/editor/webrtc.html
- wmf 14y agoThe transport is SCTP over DTLS over UDP. If they do it right it should allow out-of-order reliable delivery, which should be better than WebSocket by eliminating TCP's head-of-line blocking. http://tools.ietf.org/html/draft-ietf-rtcweb-data-channel http://tools.ietf.org/html/draft-ietf-rtcweb-data-channel http://tools.ietf.org/html/draft-jesup-rtcweb-data-protocol-01.txt http://tools.ietf.org/html/draft-jesup-rtcweb-data-protocol-...
- vr000m 14y agoYes, it may work but this is yet to be implemented or standardized.
- cmwelsh 14y agoWebRTC is available in developer versions of Google Chrome. There are some demos listed here: http://www.webrtc.org/running-the-demos http://www.webrtc.org/running-the-demos
- vr000m 14y agoI have been playing with WebRTC but the API for the data channel is yet to be implemented or available in any of the browser. Currently only MediaStream and PeerConnection has been implemented in Chrome.
- ajross 14y agoThe description of the retransmission timeout is kinda wrong. All modern TCP stacks (at least Linux and Windows, not sure about OS X) implement the selective acknowledgement ("SACK", see RFC 2018) option by default[1]. The receiver will notice the out of order sequence numbers and immediately push a SACK package back to let the sender know about the drop. And if you look at the charts, that seems to be exactly what happens. At low-but-nonzero packet loss rates, the maximum delay is never more than one or two RTTs. With high packet loss rates, you start to see a long tail of longer times due to double-loss events, I suspect. [1] "By default" becuase it can be turned off. SACK can be used as a DoS vector by forcing the sender of a large transmission to buffer and reprocess essentially all of it repeatedly by pretending it "lost" a packet.
- ehsanu1 14y agoThanks, I spent some time trying to figure out how I could configure this retransmission timeout. The SACK solution you describe sounds like a great idea. Is that the optimum solution though? Could one, say, have two TCP connections and send the same data on both? This way, maybe when one connection experiences packet loss, the other can carry on. This probably doesn't actually work due to high packet loss correlation or something (I have no idea about networking), so it would be interesting to hear what experts think. Are there any other relevant parameters to tweak in order to make TCP's performance slightly more like that of UDP? Working on an MMO game myself (for fun), so would be great to know.
- ajross 14y agoIt's a complex subject, but don't think about it as TCP being "low performance". In fact TCP will vastly outperform basically any hand-written UDP protocol at large sequential transfers over fat networks (or I guess it would be better stated that any hand-cooked protocol that performed as well as TCP would be isomorphic to TCP). The characteristic you want from UDP is out of order sequencing: you want to see the most recent packet as soon as it arrives, even if some got missed before. No version of TCP does that, because TCP is a reliable protocol which presents a stream metaphor. Packet loss will always show up as latency burps, though as I point out generally that burp is one extra RTT.
- joering2 14y agoNo later than yesterday I spent couple hours researching Websocket servers to no avail. I want to run it on Apache/Windows with PHP (there is some python implementation, but I wish it would be as simple as mod_websocked and opening concurrent port). Unfortunately solutions like Heroku are tremendously expensive in my opinion, if you want to build something that will have 1,000 websocket connections at the same time. Could not find anything reliable. This and fact IE/Opera do not have websocket implemented, makes me come back to good old Flash technology - building a simple socket module that will trigger Javascript functions inside a webpage.
- statico 14y agoOne of the tradeoffs of Heroku's great hosting solutions is that they don't support WebSockets. If you're worried about compatibility, check out PubNub or Pusher.
- joering2 14y agoPusher definitely too expensive for a project with no revenue model behind.
- ehsanu1 14y agoThis and fact IE/Opera do not have websocket implemented, makes me come back to good old Flash technology See socket.io for something even better.
- joering2 14y agoI did. My understanding is that socket.io requires Websocket server, which I am unable to build at this moment. I spent some time researching into phpWebsocket until it turned out that the project has not been updated for about 2 yars now.
- ehsanu1 14y agoSorry I didn't read your comment properly. If nothing else works, maybe you can develop with a Linux VM with a platform that already has a good websocket server (say, node.js), and host on any VPS. Good luck.