在压力测试时,连接超过4万(TCP端口共6万多),压测程序会抛出connect: cannot assign requested address.
服务端的连接可支持上百万,并经过初步分析客户度出错时TCP端口是被全部占用.
请问如何解决压力测试时 压测程序TCP端口不足的问题?
package main
import (
"golang.org/x/net/websocket"
"log"
"time"
"fmt"
)
func connect() {
origin := "http://127.0.0.1/"
url := "ws://127.0.0.1:8080/ws"
_, err := websocket.Dial(url, "", origin)
if err != nil {
log.Fatal(err)
}
}
func main() {
for i := 0; i < 100000; i++ {
go connect()
fmt.Println(i)
}
time.Sleep(time.Second * 100)
}