I have written a web API in go using gorrilla/mux framework and cassandra database. When I run a load test on the API using jmeter, it passes for some 1000 concurrent users and starts giving this error as the users increase :
Non HTTP response code: java.net.SocketException,Non HTTP response message: Socket closed
According to my understanding, this is happening because the threads are timing out. Can anyone help me regarding this?
JMeter uses the connection timeout and receive timeouts that you specify in the HTTP sampler fields.
If you haven't specified any value, it can wait for a long time to open the socket and also to receive the response. If you have configured a value for these fields, try to increase them slightly higher to observe if it helps. But it is just a troubleshooting step and most of the times, a bad idea. You need to figure out if the network connection between your test machine (JMeter) and the target system is good and not having any issues. To confirm this, open your result file in excel and you look at the 'elapsed', 'latency' and connect time fields. To add the connect time to your result file, you have to launch JMeter with the option -Jjmeter.save.saveservice.connect_time=true
You should also verify this outside Jmeter by using curl or similar tools that can give you a complete picture of the time spent.
curl -s -w '
DNS time:\t%{time_namelookup}
TCP Connect time:\t%{time_connect}
AppCon Protocol time:\t%{time_appconnect}
Redirect time:\t%{time_redirect}
PreXfer time:\t%{time_pretransfer}
StartXfer time:\t%{time_starttransfer}
Total time:\t%{time_total}
' http://www.google.com
This can give you output in the following format where TCP connect time provides the time taken by the end point to establish a connection
DNS time: 0.002
TCP Connect time: 0.003
AppCon Protocol time: 0.000
Redirect time: 0.000
PreXfer time: 0.003
StartXfer time: 0.070
Total time: 0.071
If there are no network issues, you need to find why your application is failing to process a socket creation request. I can imagine many issues including lack of sufficient threads to process the workload, less max_clients and max_processes allocated for the process etc. There can be many reasons which you can troubleshoot by capturing the wireshark dump on both the sides.
I enabled the keep-alive option in the jmeter. This solved my problem. But I still dont know how to do it using go framework.
Every Network has some limited socket size allocated to each device to transfer data. If you are using 1000 no of users from one machine, Then definitely it will allow only limited no of requests (According to channel size).
Its like "A door to pass 1000 people, and you want to pass all of them in 10 seconds"
Solution is: If you use Master-Slave and use Max 200-250 users from one machine (Ex- 4 Slaves 1 Master), You'll not get SocketException
Hope This Helps!