相关疑难解决方法(0)

'ab'程序在收到大量请求后会冻结,为什么?

每当我使用'ab'对Web服务器进行基准测试时,它会在发送大量请求后冻结一段时间,但仅在20秒左右后继续.

考虑以下用Ruby编写的HTTP服务器模拟器:

require 'socket'

RESPONSE = "HTTP/1.1 200 OK\r\n" +
           "Connection: close\r\n" +
           "\r\n" +
           "\r\n"

buffer = ""
server = TCPServer.new("127.0.0.1", 3000)  # Create TCP server at port 3000.
server.listen(1024)                        # Set backlog to 1024.
while true
    client = server.accept             # Accept new client.
    client.write(RESPONSE)             # Write a stock "HTTP" response.
    client.close_write                 # Shutdown write part of the socket.
    client.read(nil, buffer)           # Read all data from the socket.  
    client.close                       # Close it.
end
Run Code Online (Sandbox Code Playgroud)

然后我按如下方式运行ab:

ab -n 45000 -c 10 …
Run Code Online (Sandbox Code Playgroud)

sockets debugging networking throttling apachebench

37
推荐指数
2
解决办法
7457
查看次数

标签 统计

apachebench ×1

debugging ×1

networking ×1

sockets ×1

throttling ×1