我有一个非常简单的围棋服务器:Golang服务器超时
package main
import(
"net/http"
"fmt"
"log"
)
func test(w http.ResponseWriter, r *http.Request){
fmt.Println("No bid")
http.Error(w, "NoBid", 204)
}
func main() {
http.HandleFunc("/test/bid", test)
http.ListenAndServe(":8080", nil)
log.Println("Done serving")
}
我然后运行Apache的基准测试工具:
ab -c 50 -n 50000 -p post.txt http://127.0.0.1:8080/test/bid
服务器运行和响应大约15000请求,然后超时。我想知道为什么会发生这种情况,如果有什么我可以做的。
尝试运行可执行文件以下列方式:'nohup的./ [名]' – ymg
你试图关闭Request.Body? – Volker
你有什么错误(如果有的话?)。你的操作系统上有可能会打开套接字。我还建议使用wrk(https://github.com/wg/wrk)或weighttp(https://github.com/lighttpd/weighttp)而不是Apache Bench。 – elithrar