gowebsocketstress-testing

I can not exceed 28233 websocket connection on my localhost (for stress test) | Go Client (Gorilla)


I am trying to make pool of client which connect to the same websocket server (Go Server), in order to test performance and the ability to handle coming request.

I was wondering how I can reach 100K client for example, because I see when I reach 28233 gorilla client (websocket client), program can not make more.

I am getting the following error

tcp 127.0.0.1:8000: connect: cannot assign requested address

Thanks in advance


Solution

  • You cannot have 100k parallel client connections from 127.0.0.1 to 127.0.0.1:8000. Each of these parallel client connections must have a different source port (otherwise it would not be a different connection) and there are only 64k source ports available. In practice there are even less since the system will choose a port at random from the range of ephemeral ports which is even less (OS and configuration dependent).

    If the system fails to pick a unique source port not used by another connection to the same target IP and port, then you get "cannot assign requested address".

    If you want to support more parallel connections you need to vary other parameters for the connection than the source port only. Typically this is done by having not a single server socket but multiple sockets which listen on different ports.