我有一個非常簡單的圍棋服務器: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