FastCGI and nginx and post variables

Sam Smith s at msmith.net
Mon Feb 17 22:29:18 GMT 2014


Hey All,

Does anyone have simple reference code for a simple FastCGI/nginx perl script that works?

I have a HTTP POST receiving process that is going to get hit a *lot* (likely tens of thousands of hits a minute or more at peak), but only needs to write half a dozen fields to a DB and serve out a redirect. Starting by (loading/learning) a framework seems a touch excessive, and none seem particularly clear as to what happens when a single machine gets that sort of traffic. The HTTP requests themselves are several hundred bytes in, and about one hundred bytes out.


Examples I've found (even those from the last decade) seem to either pull in a load of random modules and then have errors under nginx, or have problems with POST requests (which is what this is), or just loop constantly :(


Anyone got anything handy to share for a good cause?


Cheers
Sam
  @smithsam

__DATA__

use DBI;
use CGI qw/:param/;
use FCGI;
my $dbh;
my $query;

use CGI::Fast;
use FCGI::ProcManager qw(pm_manage pm_pre_dispatch pm_post_dispatch);
use FCGI::Request;

pm_manage( n_processes => 1 );
while ($handling_request = ($request->Accept() >= 0)) {
   pm_pre_dispatch();
   &do_request();
   pm_post_dispatct();
}




More information about the london.pm mailing list