go - net/http 服务器在 ab (ApacheBench) 重负载下卡住

标签 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

最佳答案

以下是 Bill Neubauer 的解释:

This issue is caused by the OS running out of sockets. ab and Go are cycling through socket pairs for communication faster than the OS can reallocate them for reuse.

引用https://github.com/golang/go/issues/66#issuecomment-66047858

关于go - net/http 服务器在 ab (ApacheBench) 重负载下卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56088332/

相关文章:

java - 使用 Socket 实现 HTTP 服务器 - 如何让它永远运行?

go - 是否可以将测试文件放在子文件夹中

json - 当 slice 是响应的一部分时,将嵌套的数据响应展开为结构

node.js - node js监听简单httpserver的EADDRINUSE错误

caching - npm http-server 一直缓存我的 App.js

java - 如何配置 com.sun.net.httpserver 仅接受来自本地主机的请求?

node.js - AngularJS - 更新代码时,它不会反射(reflect)在侧面

date - Golang time.Parse 定义新格式类型

database - Go Select In 使用 uuid 字符串列表

go - reflect.Select 函数是为什么需要的?我假设这是因为 channel 必须是反射值?