0

I have a file on my tiny server (BeagleBoneBlack) which I want to download to another machine. Therefore I try to do it via PHP from my nginx-web-server. The file size is about 1.2 GB and the download always stops at about 410MB.

Since both computers are behind the same switch I wouldn't see a connection problem. Additionally I can rule out the possibility of software issues, cause I tested it with different PHP-software and the same problem occurs. Downloading via SCP works without a problem.

During download via PHP I see in the /proc/loadavg values like

3.15 1.17 0.46 1/95 1163
3.15 1.17 0.46 1/95 1164
3.14 1.20 0.48 1/95 1165
3.14 1.20 0.48 1/95 1166
3.21 1.25 0.50 1/95 1167
3.21 1.25 0.50 1/95 1168
3.21 1.25 0.50 1/95 1169
3.44 1.43 0.57 1/95 1172
3.42 1.52 0.61 2/95 1175
3.42 1.52 0.61 1/95 1178

and would assume that the load is quite high. Therefore I suspect the nginx-config which doesn't really fit the tiny server its running on. My nginx.conf looks like:

user www-data;
worker_processes 1;
#worker_processes 4;
pid /var/run/nginx.pid;
events {
        worker_connections 768;
        # multi_accept on;
}
http {
        ##
        # Basic Settings
        ##
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;
        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;
        include /etc/nginx/mime.types;
        default_type application/octet-stream;
        ##
        # Logging Settings
        ##
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
        ##
        # Gzip Settings
        ##
        gzip on;
        gzip_disable "msie6";
        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # nginx-naxsi config
        ##
        # Uncomment it if you installed nginx-naxsi
        ##
        #include /etc/nginx/naxsi_core.rules;
        ##
        # nginx-passenger config
        ##
        # Uncomment it if you installed nginx-passenger
        ##
        #passenger_root /usr;
        #passenger_ruby /usr/bin/ruby;
        ##
        # Virtual Host Configs
        ##
        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

Could anybody give me a hint why I cannot download bigger files ? Resp. what to change?

UPDATE: Since I get *466 writev() "/var/lib/nginx/fastcgi/1/00/0000000001" has written only 1498 of 8184 while reading upstream, client: in the nginx error-log I paste as well the config-settings for fastcgi_params:

fastcgi_param   QUERY_STRING            $query_string;
fastcgi_param   REQUEST_METHOD          $request_method;
fastcgi_param   CONTENT_TYPE            $content_type;
fastcgi_param   CONTENT_LENGTH          $content_length;
fastcgi_param   SCRIPT_FILENAME         $request_filename;
fastcgi_param   SCRIPT_NAME             $fastcgi_script_name;
fastcgi_param   REQUEST_URI             $request_uri;
fastcgi_param   DOCUMENT_URI            $document_uri;
fastcgi_param   DOCUMENT_ROOT           $document_root;
fastcgi_param   SERVER_PROTOCOL         $server_protocol;
fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;
fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;
fastcgi_param   REMOTE_ADDR             $remote_addr;
fastcgi_param   REMOTE_PORT             $remote_port;
fastcgi_param   SERVER_ADDR             $server_addr;
fastcgi_param   SERVER_PORT             $server_port;
fastcgi_param   SERVER_NAME             $server_name;
fastcgi_param   HTTPS                   $https;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param   REDIRECT_STATUS         200;

1 Answer 1

2

Is the PHP code sending the file contents (as opposed to redirecting to an actual file that nginx would serve directly)? It seems to be the case since you're experiencing high loads during the download, indicating that your server could be doing some heavy lifting instead of just passing data around.

In that case, you may be hitting PHP execution limits set through:

Be sure to also check your PHP error log and your nginx log for clues as to what else may be happening. You may want to increase the PHP reporting level setting the error_reporting php.ini directive to E_ALL and making sure an error_log file is set.

Also remember that serving files through nginx will always be more efficient than sending bytes through PHP. Especially if you're running on small / constrained hardware.

4
  • Tweaking the max_execution_time and the max_input_time resp. increasing memory_limit helped little bit, but nevertheless the system gets stuck after approx. 480MB. Your last sentence sounds nice, but how to achieve it? Reg. error-log any suggestion how to set?
    – LeO
    Sep 28, 2014 at 16:20
  • error_log should be set to a file that can be written by PHP, so you can look into it for errors. There should be something there if the PHP code suddenly stops being executed (in this case, at the 480MB mark). About my last sentence, you should instruct PHP to redirect to the path of the actual file using the header() function, passing "Location: http://my.server.tld/path/to/the/file" as a parameter. Sep 28, 2014 at 16:39
  • 1
    Checking the php-logs doesn't reveal something useful :( But inspecting once more the nginx-logs I see 2014/09/29 09:05:36 [crit] 826#0: *466 writev() "/var/lib/nginx/fastcgi/1/00/0000000001" has written only 1498 of 8184 while reading upstream,... So, should I change the question-type or ????
    – LeO
    Sep 29, 2014 at 7:25
  • I've updated the question as well.
    – LeO
    Sep 29, 2014 at 7:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .