Question

To answer my own question, it was a client issue, not a server one. For some unknown reason, my mac osx could not make over ~7.8k connections. Having ubuntu machine as a client solved the problem.


[Question]

I'm trying to estimate the maximum number of connections my server can keep. So I wrote a simple socket.io server and client test code. You can see it here. : gist

Above gist do very simple job. Server accepts all incoming socket requests, and periodically print out number of established connections, and cpu, memory usage. Client tries to connect to a given socket.io server with a certain number and does nothing but keeping connections.

When I ran this test with one server (ubuntu machine) and one client (from my mac osx), roughly 7800 connections were successfully made and it started to drop connections. So next, I ran more servers on different cpu cores, and ran the test again. What I expected is that more connections could be made (in total sum) because major bottleneck would be a CPU power. But instead what I saw was that how many cores I utilized, the total number of connections this server could keep is around 7800 connections. It's hard to understand why my server behaves like this. Can anyone give me the reason behind this behavior or point me out what I am missing?

Number of connections made before dropping any connection.

  • 1 server : 7800
  • 3 servers : 2549, 2299, 2979 (each)
  • 4 servers : 1904, 1913, 1969, 1949 (each)

Server-side command

  • taskset -c [cpu_num] node --stack-size=99999 server.js -p [port_num]

    Client-side command

  • node client.js -h http://serveraddress:port -b 10 -n 500

b=10, n=500 means that client should see 10 connections established before trying another 10 connections, until 10*500 connections are made.

Package versions

  • socket.io, socket.io-client : 0.9.16
  • express : 3.4.8
Was it helpful?

Solution

CPU is rarely the bottleneck in these types of situations. It is more likely the maximum number of TCP connections allowed by the operating system, or a RAM limitation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top