This question has been asked previously but not recently and not with a clear answer.
Using Socket.io, is there a maximum number of concurrent connections that one c
I tried to use socket.io on AWS, I can at most keep around 600 connections stable.
And I found out it is because socket.io used long polling first and upgraded to websocket later.
after I set the config to use websocket only, I can keep around 9000 connections.
Set this config at client side:
const socket = require('socket.io-client')
const conn = socket(host, { upgrade: false, transports: ['websocket'] })
For +300k concurrent connection:
Set these variables in /etc/sysctl.conf
:
fs.file-max = 10000000
fs.nr_open = 10000000
Also, change these variables in /etc/security/limits.conf
:
* soft nofile 10000000
* hard nofile 10000000
root soft nofile 10000000
root hard nofile 10000000
And finally, increase TCP buffers in /etc/sysctl.conf
, too:
net.ipv4.tcp_mem = 786432 1697152 1945728
net.ipv4.tcp_rmem = 4096 4096 16777216
net.ipv4.tcp_wmem = 4096 4096 16777216
for more information please refer to https://www.linangran.com/?p=547
This article may help you along the way: http://drewww.github.io/socket.io-benchmarking/
I wondered the same question, so I ended up writing a small test (using XHR-polling) to see when the connections started to fail (or fall behind). I found (in my case) that the sockets started acting up at around 1400-1800 concurrent connections.
This is a short gist I made, similar to the test I used: https://gist.github.com/jmyrland/5535279
After making configurations, you can check by writing this command on terminal
sysctl -a | grep file
This guy appears to have succeeded in having over 1 million concurrent connections on a single Node.js server.
http://blog.caustik.com/2012/08/19/node-js-w1m-concurrent-connections/
It's not clear to me exactly how many ports he was using though.