Seeking community wisdom on why the ApacheBench utility consistently returns a lot of "Non-2xx responses" ( 502 Bad Gateway ) when running a benchmark test of my helloworld web app using Perl's Net::Async::FastCGI and Nginx as a reverse proxy. The number of concurrent requests is pretty low at 50, but it still return lots of "Non-2xx responses"?? Any insight is greatly appreciated. Please see below for the test code and the ApacheBench command for benchmark test:

1. ApacheBench command:
Send 100 requests at concurrency level of 50:
==============================================================================
ab -l -v 2 -n 100 -c 50 "http://localhost:9510/helloworld/"<br/>
which returns:
... Concurrency Level: 50 Time taken for tests: 0.015 seconds Complete requests: 100 Failed requests: 0 Non-2xx responses: 85 #NOTE: all of these are "502 Bad Gateway" ...
2. Nginx config:
==============================================================================
location /helloworld/ { proxy_buffering off ; gzip off ; fastcgi_pass unix:/testFolder/myPath/myUDS.sock ; include fastcgi_params ; }
3. helloworld test script:
==============================================================================

use strict ; use warnings ; use IO::Async::Loop ; use Net::Async::FastCGI ; # This script will respond to HTTP requests with a simple "Hello, Worl +d!" message. #If using TCP port for communication: #my $PORT = 9890 ; #If using Unix domain socket for communication: my $uds = 'myUDS.sock' ; # Create an event loop my $loop = IO::Async::Loop->new() ; # Define the FastCGI request handler subroutine sub on_request {#Parms: request(Net::Async::FastCGI::Request); #Return +: void; my ( $fcgi, $req ) = @_ ; # Prepare the HTTP response my $response = "Hello, World!\n" ; my $respLen = length( $response ) ; # Print HTTP response headers $req->print_stdout( "Status: 200 OK" . "\n" . "Content-type: text/plain" . "\n" . "Content-length: " . $respLen . "\n" . "\n" . $response ) ; # Finish the request $req->finish() ; }#end sub # Create a new FastCGI server instance my $fcgi = Net::Async::FastCGI->new( #handle => \*STDIN , # Read FastCGI requests from STDIN on_request => \&on_request , # Assign the request handler subroutin +e ) ; # Add the FastCGI server instance to the event loop $loop->add($fcgi) ; $fcgi->listen( #service => $PORT , #if using TCP portnum addr => {# if using Unix domain socket family => "unix" , socktype => "stream" , path => "$uds" , } , #host => '127.0.0.1' , on_resolve_error => sub { print "Cannot resolve - $_[-1]\n" } , on_listen_error => sub { print "Cannot listen - $_[-1]\n" } , ) ; $SIG{ HUP } = sub { system( "rm -f $uds" ) ; exit ; } ; $SIG{ TERM } = sub { system( "rm -f $uds" ) ; exit ; } ; $SIG{ INT } = sub { system( "rm -f $uds" ) ; exit ; } ; # Run the event loop $loop->run() ;


In reply to Benchmarking Perl's Net::Async::FastCGI app consistently return LOTS of "Non-2xx responses" by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.