I got an weird error when writing some stress tests on a golang web application. Here is the code for web server
package httptest
import (
"net/http"
"testing"
)
func TestHttpTest(t *testing.T) {
http.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) {
//<-time.After(2 * time.Second)
})
http.ListenAndServe(":2222", nil)
}
When I run go test ./... and use ApacheBench to perform stress test:
ab -c 200 -n 1000 http://localhost:2222/123
It gives me following error randomly:
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
apr_socket_recv: Connection reset by peer (54)
Total of 235 requests completed
I am running the test on Mac OS 10.9. The ulimit of the os is setting as unlimited. Does anyone meet the same problem?