multithreading - Nginx with multiple thread FCGI -
could me explain situation using nginx:
nginx config:
worker_processes 1; worker_rlimit_nofile 1000; // ... worker_connections 1024; multi_accept on; use epoll; location /test_nginx { module_test_nginx; } location /test_fcgi { fastcgi_pass 127.0.0.1:8080; include fastcgi_params; }
module_test_nginx module sleep few seconds if request having parameter return "hello world"
i make 2 concurrent connections (1 firefox, 1 chrome)
1st request firefox: localhost/test_nginx?sleep=5 -> browser display "hello world" after 5 seconds
2nd request chrome: localhost/test_nginx?sleep=1 -> browser display "hello world" after 5 seconds waitting 1st request , 1 second sleep parameter
i changed worker_processes 2, then:
1st request firefox: localhost/test_nginx?sleep=5 -> browser display "hello world" after 5 seconds
2nd request chrome: localhost/test_nginx?sleep=1 -> browser display "hello world" after 1 second while firefox still loading
this testing show me module_test_nginx blocked 2nd request until 1st has been finished.
i write "hello world" fcgi program similar module_test_nginx having 2 threads in pool (i run using spawn-fcgi, port 8080)
i set worker_processes = 1, then:
1st request firefox: localhost/test_fcgi?sleep=5 -> browser display "hello world" after 5 seconds
2nd request chrome: localhost/test_fcgi?sleep=1 -> browser display "hello world" after 1 second (while firefox still loading)
so think nginx fastcgi_pass can serve more clients nginx module_test_nginx
- i make loading test with: ab, siege same concurrent connections, total connections... url 1 on firefox: localhost/test_nginx url 2 on chrome: localhost/test_fcgi both of 2 links return immediately, no sleeping. testing show me nginx module_test_nginx result better request per second rate nginx fastcgi_pass (more 3 or 4 times)
thanks reading , please me explain :)
Comments
Post a Comment