0

I'm trying to understand enough Netty to create a lightweight yet fully functional web server. I started by copying the source code examples/.../http/snoop. I run my server, and when I hit it in the browser it works fine, but it doesn't seem to work with the Apache benchmark tool. I try this to send it 10 requests:

$ 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

In the handler, there is code like this:

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");

I added an integer count variable in there, just to get a sense of what is getting called, and after the AB runs, the counter indicates that the buf.append(... line has run 1200 times. That doesn't seem right. Any ideas? Is something wrong?

4

1 回答 1

2

This sounds related to the ab bug [1] of IPv6 hosts.

[1] http://simon.heimlicher.com/articles/2012/07/08/fix-apache-bench-ab-on-os-x-lion

于 2013-03-30T21:27:12.660 回答