Nginx in docker container and cgi perl in other container

Viewed 346

I try to build the web server where nginx runs in a docker container and my Perl scripts are executed in other docker container. I used fcgiwrap + spawn-fcgi in the perl container to run scripts. It works, but it looks for me like this is single threaded. Only one request can be executed at a time. If i run myltiple requests , all will wait and only 1 runs.

Docker file for cgi container looks like

FROM ff-base

RUN apt update &&\
    apt upgrade -y &&\
    apt-get install -y spawn-fcgi fcgiwrap

EXPOSE 9001

#CMD ["/usr/sbin/fcgiwrap", "-f", "-s", "tcp:0.0.0.0:9001"]
CMD ["/usr/bin/spawn-fcgi", "-n", "-a", "0.0.0.0","-p","9001","--","/usr/sbin/fcgiwrap"]

ff-base is my image which includes perl installation based on ubuntu

I tried both CMD lines

CMD ["/usr/sbin/fcgiwrap", "-f", "-s", "tcp:0.0.0.0:9001"] and CMD ["/usr/bin/spawn-fcgi", "-n", "-a", "0.0.0.0","-p","9001","--","/usr/sbin/fcgiwrap"]

Nginx config is

     location ~* ^/cgi-bin/.+\.cgi {
         client_body_timeout  172800s;
         client_max_body_size 0;
         gzip off;
         include fastcgi_params;
         fastcgi_pass   cgi:9001;
         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;
        }

What are best configs for such cgi container? How to make it to be multithreaded to accept multiple requests? Maybe i should use some other cgi server inside the container?

Update

I have done "experiment" with my cgi container, i have replaced initialMapRegion with apache server (typical installation on ubuntu). I see exactly same problem!

But when i connect to this apache (inside docker) directly and do same upload wothout nginx in the middle , it works fast.

So, the problem maybe is how nginx retransfers input request data. Maybe it is related to networking between docker containers? i use docker-compose to run containers

1 Answers

From the docs for spawn-fcgi,

-F <children>

Number of children to fork, defaults to 1. This option doesn't work with -n, have a look at multiwatch(1) if you want to supervise multiple forks on the same socket.

Related