Here is a simple HTTP connection test (tcp) script
func main() { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "Hello, client") })) defer ts.Close() var wg sync.WaitGroup for i := 0; i < 2000; i++ { wg.Add(1) go func(i int) { defer wg.Done() resp, err := http.Get(ts.URL) if err != nil { panic(err) } greeting, err := ioutil.ReadAll(resp.Body) resp.Body.Close() if err != nil { panic(err) } fmt.Printf("%s", i, greeting) }(i) } wg.Wait() }
And if I run this on Ubuntu, I get:
panic: Get http://127.0.0.1:33202: dial tcp 127.0.0.1:33202: too many open files
Other posts say that Close connection I am doing all this here. And others say that to increase the maximum connection limit with ulimit or try sudo sysctl -w fs.inotify.max_user_watches=100000 , but it still doesnβt work.
How to run millions of gpoutines tunnels on one server? It breaks down only into 2000 connections.
Thanks,
user4211028
source share