Flame_Phoenix
Flame_Phoenix

Reputation: 17604

Is there a hard limit on socket.io connections?

Background

We have a server that has socket.io 2.0.4. This server receives petitions from a stress script that simulates clients using socket.io-client 2.0.4.

The scrip simulates the creation of clients ( each client with its own socket ) that sends a petition and immediately dies after, using socket.disconnect();

Problem

During the first few of seconds all goes well. But every test reaches a point in which the script starts spitting out the following error:

connect_error: Error: websocket error

This means that the clients my script is creating are not connecting to the server because they are unable to connect.

This script creates 7 clients per second ( spaced evenly throughout the second ), each client makes 1 petition and then dies.

Research

At first I thought there was an issue with file descriptors and limits imposed by UNIX, since the server is in a Debian machine:

After following these suggestions, the issue remained however.

Then I though maybe my test script was not connecting correctly, so I changed the connection options as in this discussion:

Still, to no avail.

What could be wrong?

I see the machine's CPU's are constantly at 100% so I guess I am pounding the server with requests. But if I am not mistaken, the server should simply accept more requests and process them when possible.

Questions

Upvotes: 3

Views: 2706

Answers (1)

Flame_Phoenix
Flame_Phoenix

Reputation: 17604

When making such stress tests one needs to be aware of protections and gate keepers.

In our case, our stack was deployed in AWS. So first, the AWS load balancers started blocking us because they thought the system was being DDOSed.

Then, the Debian system was getting flooded and it started refusing connections with SYN_FLOOD.

But after fixing that we were still having the error. Turns out we had to increase TCP connection's buffer and how TCP connections were being handled in the kernel.

Now it accepts all connections, but I wish no one the suffering we went through to find it out...

Upvotes: 3

Related Questions