Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bottleneck with sockets approach?

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.

like image 635
dev.e.loper Avatar asked Mar 20 '13 22:03

dev.e.loper


2 Answers

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
like image 187
user568109 Avatar answered Oct 24 '22 11:10

user568109


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.

like image 1
jan salawa Avatar answered Oct 24 '22 09:10

jan salawa