ab -l -v 2 -n 100 -c 50 "http://localhost:9510/helloworld/"
####
...
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"
...
####
location /helloworld/ {
proxy_buffering off ;
gzip off ;
fastcgi_pass unix:/testFolder/myPath/myUDS.sock ;
include fastcgi_params ;
}
####
use strict ;
use warnings ;
use IO::Async::Loop ;
use Net::Async::FastCGI ;
# This script will respond to HTTP requests with a simple "Hello, World!" 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 subroutine
) ;
# 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() ;