7

Thinking of creating a real-time app where users can collaborate. Found node.js + socket.io to be one of the solutions for this type of problem.

I hear from other developers that there will be a bottleneck as far as number of sockets my server will give to users. So if I have hundreds of users collaborating at same time, number of open sockets will run out and users will not be able to connect. Is this a valid concern?

update: on sort of related note I'm looking to use SockJS instead of Socket.io. There is a thread that explains pros and cons of these libraries. Also this is a good read.

dev.e.loper
  • 35,446
  • 76
  • 161
  • 247
  • JS is not the fastest language out there. Going for a C++ solution can easily quadruple your throughput if you find yourself choking on JS. The issue is not how many sockets you have, but do you manage to process them in time. – dtech Mar 21 '13 at 00:00
  • 2
    The number of file descriptors (including sockets) a process is allowed to open is configurable on all (most?) UNIX-type operating systems, usually using `ulimit` (in the shell) or `sysctl` (system wide, would still require `ulimit` as well). – robertklep Mar 21 '13 at 09:10

2 Answers2

4

For hundreds of users I don't think it is a concern.

Sockets as you know have persistent connection between the client and the server and both parties can start sending data at any time. Keeping them open is not a problem as much as the handling the load in terms of messages sent/second.

Socket.io can easily handle 1000 concurrent connections. But it will fail if it is sending more than 8-10k messages per second. You will hit the load barrier before your sockets are exhausted. In most cases handling more concurrent users translates to higher load. So don't worry about getting low on sockets. Trying to scale beyond that barrier would require more server resources.

Helpful links :

  1. Socket.IO - are the open connections a concern?
  2. http://www.quora.com/How-do-I-scale-socket-io-servers-2
Community
  • 1
  • 1
user568109
  • 47,225
  • 17
  • 99
  • 123
1

There are already solutions using this approach like Cloud9 and it works good. There will be a point where you will need to scale out. So if you are planing something big I would think about it.

Here are some tests on sockets.io with 10,000 concurrent connections. Looks like it's good solution but not easy one because of fallback mechanism.

jan salawa
  • 1,198
  • 1
  • 8
  • 25