I wrote trivial a node.js
client/server pair to test local limits on concurrent connections. No data is sent between them: 10.000 clients connect, and wait.
Each time I run the test, I spawn a server and 10 clients that create 1000 connections each.
It takes a little over 2 seconds to reach ~8000 concurrent connections. Then it stops. No errors happen (on 'error'
callbacks don't fire, close
doesn't fire either). Connections "block", with no result or timeout.
I've already raised the max file descriptor limit (ulimit -n
), and allowed more read/write memory to be consumed by the TCP stack via sysctl
(net.ipv4.tcp_rmem
and wmem
).
What's the cap I'm hitting? How can I lift it?
-- EDIT --
Server program, with logging code stripped:
clients = []
server = net.createServer()
server.on 'connection', (socket) ->
clients.push socket
server.listen 5050
Client (this runs n
times):
sockets = []
for [1..num_sockets]
socket = new net.Socket
sockets.push socket
socket.connect 5050
These are the system limits:
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