Nginx + fcgiwrap , Perl cgi. Slow upload when buffering is Off
March 25, 2022 10:23AM
I have the web app created with Perl. One of functions is upload of big files. Originally the app worked with apache. It worked fine. The core thing of the app is that there is no any buffering in apache. It forwards input request directly to perl cgi script and it reads data from input stream.

Now i need to migrate the app to Nginx. I did very common setup. Installed nginx and spawn-fcgi, fcgiwrap.

Nginx config is like

location ~* ^/cgi-bin/.+\.cgi {
client_body_timeout 172800s;
client_max_body_size 0;
gzip off;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9001;
fastcgi_param NO_BUFFERING 1;
fastcgi_request_buffering off;
fastcgi_read_timeout 900s;
fastcgi_send_timeout 900s;
fastcgi_ignore_client_abort on;
fastcgi_keep_conn on;
fastcgi_socket_keepalive on;
}

The problem is that upload with my app is very slow. Because of buffering is off.

When i change settings to

#fastcgi_param NO_BUFFERING 1;
fastcgi_request_buffering on;

to enable buffering, all works fast. Upload of 50mb file needs couple seconds. However this doesn't work for me, because in case of 5GB file i can not wait while buffered.

But when buffering is disabled upload is slow. And i checked with test perl script that data in the script are received slowly. It looks like nginx transfer data somehow too slow.

Additionally, i tested the setup when spawn-fcgi+fcgiwrap is replaced with apache. So, nginx proxies to apache. In this case upload is also slow. But direct request to apache is super fast.

What can this be? Any ideas?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 280
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready