Hacker News new | ask | show | jobs
by agnoster 5598 days ago
I'm tempted to actually do a quick test, but I think it probably comes down to something like whether you're closer to the duostack servers or the instantdomainsearch servers.

The reason this is with WebSockets isn't because I needed the speed of them - it's because I wanted to play with [socket.io](http://socket.io/), which provides a really nice abstraction for bidirectional communication, and I wanted to play with Nodejs. It seemed like The Thing To Play With.

The original domainzomg actually loaded hidden images and used onLoad and onSuccess handlers so in theory you didn't even need XMLHttpRequest support in your browser for it to work. So that's the opposite end of the spectrum. Then I figured I'd try rewriting it for ease of maintainability. It's really just a tool I use myself, and a couple friends started using. I'm going to use whatever technology I feel like playing with at the time.

Also, I'm not technically versed in how multiple requests on an HTTP 1.1 connection would work, it's possible that it may even be slightly faster if you just have one XHR request rather than 3 WebSocket requests. WebSockets should be used when you need to push data to the client that isn't part of a direct request-response loop - if you have the request-response loop, XHR is just fine.

tl;dr: 100% right that WebSocket doesn't always get you performance improvements (it might even be slower for some use cases), but socket.io is a super nice abstraction layer that makes programming more fun.