net/http 服务器在 ab (ApacheBench) 重负载下冻结



Golangnet/httpMacOS 上的服务器在 16000 个请求后冻结:

$ ab -c 4 -n 20000 http://127.0.0.1:8080/
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 2000 requests
Completed 4000 requests
...
Completed 14000 requests
Completed 16000 requests
^C

以下是Bill Neubauer的解释:

此问题是由操作系统插槽不足引起的。 ab 和 Go 是 循环使用套接字对,实现比操作系统更快的通信速度 重新分配它们以供重用。

请参阅 https://github.com/golang/go/issues/66#issuecomment-66047858

最新更新