Node.js concurrent connection restriction

I wrote a trivial client / server pair node.jsto check local restrictions on concurrent connections. There is no data between them: 10,000 clients connect and wait.

Each time I run the test, I create a server and 10 clients, each of which creates 1000 connections.

It takes just over 2 seconds to reach ~ 8000 concurrent connections. Then he stops. No errors occur ( on 'error'callbacks do not work, closedo not work). Block connections, with no result or timeout.

I already set the maximum file descriptor limit ( ulimit -n) and allowed more read / write memory to consume the TCP stack through sysctl( net.ipv4.tcp_rmemand wmem).

Which cap do I hit? How can I lift it?

- EDIT -

Server program with disabled registration code:

clients = []

server = net.createServer()

server.on 'connection', (socket) ->
    clients.push socket

server.listen 5050

Client (executed nonce):

sockets = []

for [1..num_sockets]
    socket = new net.Socket
    sockets.push socket
    socket.connect 5050

These are the system limitations:

sysctl -w net.ipv4.ip_local_port_range="500 65535"  
sysctl -w net.ipv4.tcp_tw_recycle="1"               
sysctl -w net.ipv4.tcp_tw_reuse="1"                 

sysctl -w net.ipv4.tcp_rmem="4096 87380 16777216"   
sysctl -w net.ipv4.tcp_wmem="4096 16384 16777216"   

sysctl -w fs.file-max="655300"                      
sysctl -w fs.nr_open="3000000"                      

ulimit -n 2000000
+4
source share

Source: https://habr.com/ru/post/1542806/


All Articles