2013-03-30 28 views
0

我想了解足夠的Netty來創建一個輕量級但功能完備的Web服務器。我從複製源代碼examples/.../http/snoop開始。我運行我的服務器,當我在瀏覽器中打開它時,它工作正常,但它似乎不適用於Apache基準測試工具。我試試這個將其發送10個請求:Netty 4 http snoop示例中的錯誤,使用apache基準測試

$ 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次。這看起來不正確。有任何想法嗎?有什麼問題嗎?

回答