# Hello world upload\_module adds 2 sec delay to file uploads

**URL:** <https://www.ruby-forum.com/t/hello-world-upload-module-adds-2-sec-delay-to-file-uploads/170791>\
**Category:** NGINX\
**Created:** [June 22, 2009, 9:25pm UTC](https://www.ruby-forum.com/t/hello-world-upload-module-adds-2-sec-delay-to-file-uploads/170791 "2009-06-22T21:25:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cc9497/32.png) [@jack](https://www.ruby-forum.com/u/jack)\
**Post date:** [June 22, 2009, 9:25pm UTC](https://www.ruby-forum.com/t/hello-world-upload-module-adds-2-sec-delay-to-file-uploads/170791/1 "2009-06-22T21:25:39Z")

</div>

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](http://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](http://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:

> **[Hello world upload\_module adds 2 sec delay to file uploads](https://forum.nginx.org/read.php?2,3264,3264#msg-3264)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![jack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cc9497/32.png) [@jack](https://www.ruby-forum.com/u/jack)\
**Post date:** [June 22, 2009, 10:03pm UTC](https://www.ruby-forum.com/t/hello-world-upload-module-adds-2-sec-delay-to-file-uploads/170791/2 "2009-06-22T22:03:21Z")

</div>

What are the other debug log messages? I’m not sure I can give relevant  
answer with so few information.

---

<div class="post-metadata">

**Author:** ![jack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cc9497/32.png) [@jack](https://www.ruby-forum.com/u/jack)\
**Post date:** [June 23, 2009, 4:27pm UTC](https://www.ruby-forum.com/t/hello-world-upload-module-adds-2-sec-delay-to-file-uploads/170791/3 "2009-06-23T16:27:08Z")

</div>

I was able to remove the two second delay by changing my curl command to  
the following:  
curl -H ‘Expect: 100-continue’ -F ‘file1=@/tmp/hworld’  
‘localhost:81/upload/this’

(For reference it was curl -F ‘file1=@/tmp/hworld’  
‘localhost:81/upload/this’)

Posted at Nginx Forum:

> **[Re: Hello world upload\_module adds 2 sec delay to file uploads](https://forum.nginx.org/read.php?2,3264,3268#msg-3268)**
>
> 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...
