I am writing socket.io-client node.js bot app in order to test performance of my socket.io based server application also running under node.
Usually the server runs ubuntu linux but I also have the same server app (node.js, nginx, socket.io) installed and configured on my local dev machine.
If I start my bot-"script" and launch 200 bots that create individual connections to the server I have no problem whatsoever if I do it to the real server(s), the linux servers.
But if I connect to my local os x based "server" I cannot really get over ~120 connections.
I get disconnects, stale sockets, and an infinite loop of disconnect/reconnect which under the standard settings of socket.io will just take longer and longer to complete (delayed reconnection attempt).
My local dev machine is under almost 0% load during such a test, so it is not related to memory or processor.
I have tried the same bot-script from a second local machine, to ensure the issue was not related to the bots running on the same machine as the server. But I get the same issue.
As soon as I point the bot-script towards the real servers I have no issues whatsoever.
When I am in the range where the issue occurs, i.e. pushing with more than 120 clients, I have tried to access my local dev-server with a browser (the real user-scenario) and refresh many times. Sometimes I get a "internal server 500".
Makes me think that maybe this is not socket.io related by rather nginx? or some other basic socket limitation on a regular os x (non server) machine?
All the googling I did before posting this question..... and 3 minutes after doing so I stumbled upon the answer:
Write in terminal:
sysctl -a | grep somax
I got the answer:
kern.ipc.somaxconn: 128
so case is pretty closed I guess.
One just write in terminal:
sudo sysctl -w kern.ipc.somaxconn=xyz
where xyz is the number of connections to allow.
Found answer here: http://b.oldhu.com/2012/07/19/increase-tcp-max-connections-on-mac-os-x/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With