Hello world upload_module adds 2 sec delay to file uploads

jack nginx-forum at nginx.us
Mon Jun 22 23:13:51 MSD 2009


Uploading a small "hello world" file using upload_module takes about 2 seconds, while not using upload_module and passing it directly to my fastcgi is almost instantaneous.  To debug the problem I modified the upload_module code and added a debug statement at the end of function ngx_http_upload_handler, and another at the beginning of the function ngx_http_read_upload_client_request_body_handler.

Using nginx_upload_module-2.0.9

2009/06/22 12:02:56  16737#0: *1 returning ok in ngx_http_upload_handler, client: 127.0.0.1, server: myhost.com, request: "POST /upload/this HTTP/1.1", host: "localhost:81"
2009/06/22 12:02:58  16737#0: *1 67964 begin ngx_http_read_upload_client_request_body_handler , client: 127.0.0.1, server: myhost.com, request: "POST /upload/this HTTP/1.1", host: "localhost:81"

Notice the 2 second delay between those calls.  Are there other settings I could tweak to get that 2 second delay down?


Here is my nginx.conf


-----------------
user  www www;
worker_processes  5;
worker_rlimit_nofile 8192;
error_log  logs/error.log  info;
pid        logs/nginx.pid;
events {
    worker_connections  2000;
}
http {
    include       mime.types; # Default for now
    default_type  application/octet-stream;
    access_log  logs/access.log;
    sendfile        on;
    tcp_nopush     on;
    keepalive_timeout  65;
    upstream upload_workers {
      server localhost:2121;
      server localhost:2122;
      server localhost:2123;
      server localhost:2124;
    }
    server {
        listen       81;
        location /upload {
             # This needs to remain large
            client_max_body_size 1000M;
            upload_pass   @upload_taker;
            upload_store /tmp;
            upload_store_access user:rw group:rw all:rw;
            upload_set_form_field $upload_field_name.name "$upload_file_name";
            upload_set_form_field $upload_field_name.content_type "$upload_content_type";
            upload_set_form_field $upload_field_name.path "$upload_tmp_path";
            # Integrity checking.  Optional.
#            upload_aggregate_form_field "$upload_field_name.md5" "$upload_file_md5";
#            upload_aggregate_form_field "$upload_field_name.size" "$upload_file_size";
            upload_cleanup 400 404 499 500-505;
        }
        # Pass altered request body to a backend
        location @upload_taker {
          include fastcgi_params;
          fastcgi_pass upload_workers;
        }
        location / {
          index index.html;
        }
        error_page  404              /404.html;
    }
}

----------

To post to nginx, I'm using
echo "Hello world" > /tmp/hworld
curl -F 'file1=@/tmp/hworld' 'localhost:81/upload/this'

Thanks for any help!

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,3264,3264#msg-3264






More information about the nginx mailing list