Skip to content

Nginx AIO threads for Concurrent Request

Taymindis Woon edited this page Sep 22, 2018 · 12 revisions

nginx-C-function with AIO threads request feature (has been tested on version 1.8.1 and above)

sometimes one worker only can process one request per time, what if process the heavy app request might slow down the performance due to synchronize process.

Resolution:- enable the multi threading request, just recompile your nginx by using --with-threads.

After installed, enable the multithread in your server block

http {
    server {
        listen 8080;
        aio threads;
        ngx_http_c_func_link_lib "/etc/nginx/apps/libcfuntest.so";

        location /callme {
            ngx_http_c_func_call "my_app_simple_get_greeting"; 
           # ngx_http_c_func_call "my_app_simple_get_greeting" respTo=myRespVariable;
           # return 200 $myRespVariable;
        }
    }
}

Now your app can accept more than one request from client, enjoy :)

Compilation References: https://www.nginx.com/blog/thread-pools-boost-performance-9x/

Clone this wiki locally