A question of fastcgi_pass method

SanCao Jie sancaojie at gmail.com
Sun Oct 17 14:42:51 MSD 2010


 HI,

I'm a chinese ,sorry for my poor english.

I'm new to nginx. I have installed nginx 0.7.67  ,and installed flup
,web.py  to use python .
I writer a simple test.py file  ,and just run : python test.py   . VIsit
http://ip:8080  and it works well.
That means the web.py  is  right installed.

So, I try to use nginx with this python file.
I edit the nginx.conf like this:

             fastcgi_pass 127.0.0.1:9000;
             fastcgi_param SERVER_NAME $server_name;
             fastcgi_param SERVER_PORT $server_port;
             fastcgi_param SERVER_ADDR $server_addr;
             fastcgi_param REMOTE_ADDR $remote_addr;
             fastcgi_param REMOTE_PORT $remote_port;
             fastcgi_param SERVER_PROTOCOL $server_protocol;
             fastcgi_param PATH_INFO $fastcgi_script_name;
             fastcgi_param REQUEST_METHOD $request_method;
             fastcgi_param QUERY_STRING $query_string;
             fastcgi_param CONTENT_TYPE $content_type;
             fastcgi_param CONTENT_LENGTH $content_length;


and use spawn-fcgi to start up the python file :

            spawn-fcgi -f FILE -a 127.0.0.1 -p 9000

then visit the address  http://ip   it works ,shows the result what I wanted
.

and then  I  simply change the fastcgi_pass method  TCP to  UNIX SOCKET

nginx.conf :    fastcgi_pass unix:/tmp/nginx.socket

spawn-fcgi command : spawn-fcgi -f FILE -s /tmp/nginx.socket   ( And change
the mod of /tmp/nginx.socket to 777 ).

This times  it works well too .


Then I just did a simple test for this two different way of connections
between nginx and spawn-fcgi .

I use webbench to do this test  :  webbench -c 100 http://IP/

This is the result:

USE TCP Method:

Speed=5730 pages/min, 14038 bytes/sec.
Requests: 2865 susceed, 0 failed.

USE UNIX SOCKET Method:

Speed=5548 pages/min, 13592 bytes/sec.
Requests: 2774 susceed, 0 failed.

Why the test shows that TCP method is faster than Unix Socket ?

And an  other quertion is :during the TCP Method test ,I typed : netstat -an
| grep 9000  ,this were many ports shows
TIME WAIT .almost over 3,000 . when the webbench is over ,zhe TIME WAIT
ports number is decrease.
Why this ,And is it safe ?


THANKS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20101017/e1f2f66c/attachment.html>


More information about the nginx mailing list