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

时间:2019-05-11 07:51:57

标签: go httpserver

MacOS上的Golang net/http服务器在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

1 个答案:

答案 0 :(得分:-2)

以下是Bill Neubauer的解释:

  

此问题是由操作系统的套接字用尽引起的。 Ab和Go是   通过套接字对循环以实现比OS更快的通信速度   重新分配它们以供重用。

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