nginx, fcgi+perl forking a new process per request ...

Stefan Parvu sparvu at systemdatarecorder.org
Mon Mar 15 15:13:28 MSK 2010


Hi,

Im trying to experiment more regarding nginx + fcgi,perl. Im using the
following configuration:

OS: Solaris 10 x86
Perl CGI support: nginx-fcgi-0.4.3
http://www.nginx.eu/nginx-fcgi.html

worker_processes  1;

        location ~ ^/cgi-bin/.*\.cgi$ {
            gzip off;
            fastcgi_pass    unix:/opt/sdr/report/ws/fastcgi_temp/nginx-fcgi.sock;
            fastcgi_read_timeout    5m;
            fastcgi_index    index.cgi;
            #
            #  You may copy and paste the lines under or use include directive
            #  include  /etc/nginx/nginx-fcgi.conf;
            #  In this example all is in one file
            #
            fastcgi_param    SCRIPT_FILENAME  /opt/sdr/report/docroot/$fastcgi_script_name;
            fastcgi_param    QUERY_STRING  $query_string;
            fastcgi_param    REQUEST_METHOD  $request_method;
            fastcgi_param    CONTENT_TYPE  $content_type;
            fastcgi_param    CONTENT_LENGTH  $content_length;
            fastcgi_param    GATEWAY_INTERFACE  CGI/1.1;
            fastcgi_param    SERVER_SOFTWARE  nginx;
            fastcgi_param    SCRIPT_NAME  $fastcgi_script_name;
            fastcgi_param    REQUEST_URI  $request_uri;
            fastcgi_param    DOCUMENT_URI  $document_uri;
            fastcgi_param    DOCUMENT_ROOT  $document_root;
            fastcgi_param    SERVER_PROTOCOL  $server_protocol;
            fastcgi_param    REMOTE_ADDR  $remote_addr;
            fastcgi_param    REMOTE_PORT  $remote_port;
            fastcgi_param    SERVER_ADDR  $server_addr;
            fastcgi_param    SERVER_PORT  $server_port;
            fastcgi_param    SERVER_NAME  $server_name;
        }


I have all processes running, ptree command:

5548  /opt/sdr/report/perl/bin/perl /opt/sdr/report/ws/sbin/nginx-fcgi -l /opt/sdr/re
5552  /opt/sdr/report/ws/sbin/nginx -c /opt/sdr/report/ws/conf/nginx.conf
  5553  /opt/sdr/report/ws/sbin/nginx -c /opt/sdr/report/ws/conf/nginx.conf

When I kick a jmeter test against the server I can see dozens of processes
forked by the 5548 the master FCGI process. As understood I should not
see this behavior when using FastCGI, isnt it ?

Example, using DTrace:

# /opt/csw/bin/execsnoop 
  UID    PID   PPID ARGS
60001  18035   5548 /opt/sdr/report/perl/bin/perl -wT /opt/sdr/report/docroot//cgi-bin/initial.cgi 
60001  18038   5548 /opt/sdr/report/perl/bin/perl -wT /opt/sdr/report/docroot//cgi-bin/initial.cgi 
60001  18039   5548 /opt/sdr/report/perl/bin/perl -wT /opt/sdr/report/docroot//cgi-bin/initial.cgi 
60001  18040   5548 /opt/sdr/report/perl/bin/perl -wT /opt/sdr/report/docroot//cgi-bin/initial.cgi 
60001  18041   5548 /opt/sdr/report/perl/bin/perl -wT /opt/sdr/report/docroot//cgi-bin/initial.cgi 
60001  18042   5548 /opt/sdr/report/perl/bin/perl -wT /opt/sdr/report/docroot//cgi-bin/initial.cgi 
60001  18044   5548 /opt/sdr/report/perl/bin/perl -wT /opt/sdr/report/docroot//cgi-bin/initial.cgi 
60001  18045   5548 /opt/sdr/report/perl/bin/perl -wT /opt/sdr/report/docroot//cgi-bin/initial.cgi 
60001  18046   5548 /opt/sdr/report/perl/bin/perl -wT /opt/sdr/report/docroot//cgi-bin/initial.cgi 
60001  18031   5548 /opt/sdr/report/perl/bin/perl -wT /opt/sdr/report/docroot//cgi-bin/initial.cgi 
60001  18032   5548 /opt/sdr/report/perl/bin/perl -wT /opt/sdr/report/docroot//cgi-bin/initial.cgi 
60001  18033   5548 /opt/sdr/report/perl/bin/perl -wT /opt/sdr/report/docroot//cgi-bin/initial.cgi 
60001  18034   5548 /opt/sdr/report/perl/bin/perl -wT /opt/sdr/report/docroot//cgi-bin/initial.cgi 
60001  18036   5548 /opt/sdr/report/perl/bin/perl -wT /opt/sdr/report/docroot//cgi-bin/initial.cgi 
60001  18037   5548 /opt/sdr/report/perl/bin/perl -wT /opt/sdr/report/docroot//cgi-bin/initial.cgi 
60001  18043   5548 /opt/sdr/report/perl/bin/perl -wT /opt/sdr/report/docroot//cgi-bin/initial.cgi 
60001  18047   5548 /opt/sdr/report/perl/bin/perl -wT /opt/sdr/report/docroot//cgi-bin/initial.cgi 
60001  18048   5548 /opt/sdr/report/perl/bin/perl -wT /opt/sdr/report/docroot//cgi-bin/initial.cgi 

[...]


Any ideas ?


Thanks,
Stefan





More information about the nginx mailing list