我试图了解足够的Netty来创建一个轻量级但功能齐全的Web服务器。我开始复制源代码examples/.../http/snoop
。我运行我的服务器,当我在浏览器中点击它时工作正常,但它似乎不适用于Apache基准测试工具。我试着发送10个请求:
$ ab -n 10 http://localhost:8080/foo
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)...apr_socket_recv: Connection reset by peer (54)
Total of 7 requests completed
在处理程序中,有这样的代码:
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof HttpRequest) {
HttpRequest request = this.request = (HttpRequest) msg;
...
buf.append("WELCOME TO THE WILD WILD WEB SERVER\r\n");
我在那里添加了一个整数计数变量,只是为了了解被调用的内容,并且在AB运行之后,计数器指示buf.append(...
行已运行1200次。这似乎不对。有任何想法吗?有什么不对吗?
答案 0 :(得分:2)
这听起来与IPv6主机的ab bug [1]有关。
[1] http://simon.heimlicher.com/articles/2012/07/08/fix-apache-bench-ab-on-os-x-lion