Introducing Socket.io 1.0
socket.io
socket.io
Dominic Tarr, substack, and others have been advocating this idea for awhile: https://github.com/substack/stream-handbook
Gluing together various types of streams and stream transformers is a really nice way to build certain types of applications.
Fortunately it should be easy to write a Stream compatible wrapper.
https://github.com/primus/primus
(Primus uses engine.io,sockjs,browserchannel,websockets internally so you're no longer locked into a specific framework)
why would I need engine.io,websockets for example when engine.io already uses websockets if it can upgrade the connection to them?
You can tell engine.io to only use websockets, but what's the point if you can use websockets directly and have the same API?
For a good debate on this with the creator of SockJS: https://groups.google.com/forum/#!topic/sockjs/lgzxVnlth54
How does that affect scalability, or how is that related to your comment?
Disclaimer: I work at Automattic, we've been using engine.io on cloudup.com for a while.
A scalability question:
You note "Turn on sticky load balancing (for example by origin IP address). This ensures that long-polling connections for example always route requests to the same node where buffers of messages could be stored."
I read this to mean that we are responsible (in our load balancer/proxy/etc) to keep connections from clients returning to the same server. This is OK, but what about nodeJS clusters? How should I ensure that client A always connects to cluster-node member 3?
Related section of the blog post: http://socket.io/blog/introducing-socket-io-1-0/#scalability
I would do significant load testing for each use case before using it (or socket.io for that matter). I needed to push 30-50 messages per second to each connected client and faye started choking as soon as there were more than 20-30 clients. socket.io would choke at around 50-100 connected clients. Raw websockets were able to reach closer to 100 clients but performed more or less similar to socket.io.
We kept the design simple, otherwise a "batching" mechanism could be introduced that would replay a single batch of 50 messages but that would make everything a second delayed. However, part of the map allows you to login and see your messages live on the screen as you're sending them to your partner and for that the real time streaming is pretty critical.
Would be pretty hesitant to use it until there's some sort of closure on this.
We had two issues with sticky load balancing:
1. AWS ELB had to run in TCP mode (for websockets) which meant no stickiness
2. Within each instance we have a node-cluster running to utilize multiple CPUs and putting haproxy with stickiness there increased complexity
We could avoid using the ELB but then you lose the ability to use an EC2 Auto Scaling group, introducing significant admin overhead.
Ultimately we didn't need the nodes communicating between each other (it's a one way stream from us to the client) so raw websockets ended up being the simplest solution.
Task Manager shows no unusual CPU activity beyond the initial page load.
No module lock-in!
Yes i'm a bit biased.
Also, incredible job on the new website. Seriously love it. All around great work, if there was a Gittip button on the website I would have already clicked it.
I am trying to develop an application that can be horizontally scaled. I understand using the socket.io-redis package seems to allow you to emit to a particular socketid from one instance while that connection itself is connected to another machine and the redis connection will take care of the communicating. This in a sense abstracts away the fact that there are multiple servers by just taking care of it transparently.
Are there any provisions within socket.io or another package that allows you to sync normal js objects across servers as well? The alternative as I see it is to use redis pub/sub to keep the state in sync but this feels like it should be a solved problem that one need not reinvent the wheel for.
EDIT: found it at http://socket.io/demos/computer/
Anyone know of any projects working towards getting this new version to work on native iOS/Android?
At first I thought that the article's author forgot to replace an intranet link.. nope its a new tld here to mess with our heads!
Is it possible to create own implementation of socket.io server side code?
- Changed some things (method names, and so on) with no reason - It's not possible to use a custom logger anymore - I can't access the list of rooms anymore (or it changed and they didn't documented it yet)
Somebody else ?
https://github.com/visionmedia/debug
The DEBUG variable holds a comma separated list of names (or wildcard patterns) used to narrow the scope of the debug output.
For example, to get debug information about the internal components of socket.io and express, you could do:
DEBUG=socket.io:,express: node index.js
There really isn't a big chance of hitting problems with the DEBUG variable, since it's defined locally to the command and not exported, and there's already a reasonably well established convention of using it like that for node modules.
I prefer to think in standardized terms like KBs, not lines of code.
EDIT: For the downvoters, I am just saying that it would have been more beneficial to myself had they of addressed their improvement in terms of a percentage of code reduction or actual measurable size of their code. I was not trying to be snarky.
offtopic: please fix your blog, it breaks the browser history in IE 11 (spammed with hash entries)
"The benefits of this particular modularization can’t be overstated"
Would be great to see some benchmark of how this can scale especially with the new redis integration.