# Slow file upload on OS X server

**URL:** <https://www.ruby-forum.com/t/slow-file-upload-on-os-x-server/123874>\
**Category:** NGINX\
**Created:** [December 21, 2007, 4:41pm UTC](https://www.ruby-forum.com/t/slow-file-upload-on-os-x-server/123874 "2007-12-21T16:41:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jamey\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/5e9695/32.png) [@Jamey\_C](https://www.ruby-forum.com/u/Jamey_C)\
**Post date:** [December 21, 2007, 4:41pm UTC](https://www.ruby-forum.com/t/slow-file-upload-on-os-x-server/123874/1 "2007-12-21T16:41:21Z")

</div>

I have a rails app running on an OS X server, using nginx as the web  
server,  
proxying to a mongrel cluster. File uploads from the user’s browser are  
painfully slow when going through nginx, but if I target an individual  
mongrel instance in the browser, the file upload is fast. I have the  
latest  
mac ports version of nginx installed (0.54, I believe).

Any ideas? I tried changing the log format, as suggested in a reply to  
someone else’s post, but could not get nginx to start, so I don’t know  
if  
nginx has to be compiled with a particular flag in order to include the  
log  
format config directive in nginx.conf.

Any help, suggestions would be greatly appreciated.

Jamey C.

---

<div class="post-metadata">

**Author:** ![Jamey\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/5e9695/32.png) [@Jamey\_C](https://www.ruby-forum.com/u/Jamey_C)\
**Post date:** [December 22, 2007, 5:06pm UTC](https://www.ruby-forum.com/t/slow-file-upload-on-os-x-server/123874/2 "2007-12-22T17:06:17Z")

</div>

On Dec 21, 2007 10:28 AM, Jamey C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Any help, suggestions would be greatly appreciated.
> 
> Jamey C.

Try turning sendfile off in the config.

~Wayne

---

<div class="post-metadata">

**Author:** ![Jamey\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/5e9695/32.png) [@Jamey\_C](https://www.ruby-forum.com/u/Jamey_C)\
**Post date:** [December 22, 2007, 8:20pm UTC](https://www.ruby-forum.com/t/slow-file-upload-on-os-x-server/123874/3 "2007-12-22T20:20:53Z")

</div>

no sendfile on os x

---

<div class="post-metadata">

**Author:** ![Jamey\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/5e9695/32.png) [@Jamey\_C](https://www.ruby-forum.com/u/Jamey_C)\
**Post date:** [December 22, 2007, 10:48pm UTC](https://www.ruby-forum.com/t/slow-file-upload-on-os-x-server/123874/4 "2007-12-22T22:48:18Z")

</div>

Well, I turned off sendfile in config. I also changed a bunch of  
parameters  
per an email I received from Dave C. (thanks Dave!). No luck.

Just for laughs, I installed and configured Swiftiply with Mongrel and  
turned off Nginx. Same issue.

So, then I turned off Swiftiply also and started just one mongrel and  
told  
it to listen on port 80. It worked great. File uploads were much  
faster.

So, if I am having the same issue when proxying from either Swiftiply or  
Nginx, but I don’t have the slowness issue when I don’t proxy and just  
go  
straight to the mongrel instance, this tells me the problem is not with  
Nginx, but must be some setting on the OS X server.

Does anyone know what would cause proxying in general to be slow on an  
OS X  
server? I know its not the network speed from the browser to the  
server,  
because when I was connecting directly to the mongrel instance without  
proxying, file uploads were fine.

Sorry for asking this (probably) non-nginx related question on the list,  
but  
I started it here, so I figured I would ask one more question.

Thanks.

Jamey C.

---

<div class="post-metadata">

**Author:** ![Jamey\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/5e9695/32.png) [@Jamey\_C](https://www.ruby-forum.com/u/Jamey_C)\
**Post date:** [December 31, 2007, 7:27pm UTC](https://www.ruby-forum.com/t/slow-file-upload-on-os-x-server/123874/5 "2007-12-31T19:27:21Z")

</div>

Ok, I compiled nginx from scratch so I could include the with-debug  
option.  
What happens is that I click on the submit button and the error.log  
shows  
nginx cranking through the same messages, which I will show below.  
After a  
minute or so, it finally starts uploading the file. I have copied the  
last  
part of the debug messages that show it cranking (and not doing  
anything)  
after I clicked on the upload button, and then the log shows the first  
part  
of when it finally starts uploading. Does the fact that it keeps  
showing  
“accept mutex lock failed” and then finally, when it starts uploading,  
it  
shows “accept mutex locked”, does this mean anything?

Here is the snippet from the log file:

2007/12/31 10:07:10 [debug] 22764#0: worker cycle  
2007/12/31 10:07:10 [debug] 22766#0: accept mutex lock failed: 0  
2007/12/31 10:07:10 [debug] 22764#0: accept mutex lock failed: 0  
2007/12/31 10:07:10 [debug] 22766#0: kevent timer: 500, changes: 0  
2007/12/31 10:07:10 [debug] 22764#0: kevent timer: 500, changes: 0  
2007/12/31 10:07:10 [debug] 22766#0: kevent events: 0  
2007/12/31 10:07:10 [debug] 22766#0: timer delta: 500  
2007/12/31 10:07:10 [debug] 22764#0: kevent events: 0  
2007/12/31 10:07:10 [debug] 22766#0: posted events 00000000  
2007/12/31 10:07:10 [debug] 22764#0: timer delta: 500  
2007/12/31 10:07:10 [debug] 22766#0: worker cycle  
2007/12/31 10:07:10 [debug] 22764#0: posted events 00000000  
2007/12/31 10:07:10 [debug] 22766#0: accept mutex lock failed: 0  
2007/12/31 10:07:10 [debug] 22764#0: worker cycle  
2007/12/31 10:07:10 [debug] 22766#0: kevent timer: 500, changes: 0  
2007/12/31 10:07:10 [debug] 22764#0: accept mutex lock failed: 0  
2007/12/31 10:07:10 [debug] 22764#0: kevent timer: 500, changes: 0  
2007/12/31 10:07:11 [debug] 22766#0: kevent events: 0  
2007/12/31 10:07:11 [debug] 22766#0: timer delta: 500  
2007/12/31 10:07:11 [debug] 22766#0: posted events 00000000  
2007/12/31 10:07:11 [debug] 22766#0: worker cycle  
2007/12/31 10:07:11 [debug] 22764#0: kevent events: 0  
2007/12/31 10:07:11 [debug] 22764#0: timer delta: 500  
2007/12/31 10:07:11 [debug] 22764#0: posted events 00000000  
2007/12/31 10:07:11 [debug] 22764#0: worker cycle  
2007/12/31 10:07:11 [debug] 22764#0: accept mutex lock failed: 0  
2007/12/31 10:07:11 [debug] 22764#0: kevent timer: 500, changes: 0  
2007/12/31 10:07:11 [debug] 22766#0: accept mutex lock failed: 0  
2007/12/31 10:07:11 [debug] 22766#0: kevent timer: 500, changes: 0  
2007/12/31 10:07:11 [debug] 22765#0: kevent events: 0  
2007/12/31 10:07:11 [debug] 22765#0: timer delta: 65000  
2007/12/31 10:07:11 [debug] 22765#0: \*4 event timer del: 10: 828555818  
2007/12/31 10:07:11 [debug] 22765#0: \*4 http keepalive handler  
2007/12/31 10:07:11 [debug] 22765#0: \*4 close http connection: 10  
2007/12/31 10:07:11 [debug] 22765#0: \*4 free: 00000000  
2007/12/31 10:07:11 [debug] 22765#0: \*4 free: 00000000  
2007/12/31 10:07:11 [debug] 22765#0: \*4 free: 00000000  
2007/12/31 10:07:11 [debug] 22765#0: \*4 free: 00000000  
2007/12/31 10:07:11 [debug] 22765#0: \*4 free: 00500510, unused: 48  
2007/12/31 10:07:11 [debug] 22765#0: posted events 00000000  
2007/12/31 10:07:11 [debug] 22765#0: worker cycle  
2007/12/31 10:07:11 [debug] 22765#0: accept mutex locked  
2007/12/31 10:07:11 [debug] 22765#0: kevent timer: -1, changes: 0  
2007/12/31 10:07:11 [debug] 22765#0: kevent events: 1  
2007/12/31 10:07:11 [debug] 22765#0: kevent: 7: ft:-1 fl:0005  
ff:00000000  
d:1 ud:002C3000  
2007/12/31 10:07:11 [debug] 22765#0: post event 002C3000  
2007/12/31 10:07:11 [debug] 22765#0: timer delta: 10  
2007/12/31 10:07:11 [debug] 22765#0: posted event 002C3000  
2007/12/31 10:07:11 [debug] 22765#0: delete posted event 002C3000  
2007/12/31 10:07:11 [debug] 22765#0: accept on 0.0.0.0:9000, ready: 1  
2007/12/31 10:07:11 [debug] 22765#0: malloc: 00500510:256  
2007/12/31 10:07:11 [debug] 22765#0: \*7 accept: 127.0.0.1 fd:10  
2007/12/31 10:07:11 [debug] 22765#0: \*7 event timer add: 10:  
60000:828615828  
2007/12/31 10:07:11 [debug] 22765#0: \*7 kevent set event: 10: ft:-1  
fl:0025  
2007/12/31 10:07:11 [debug] 22765#0: posted event 00000000  
2007/12/31 10:07:11 [debug] 22765#0: posted events 00000000  
2007/12/31 10:07:11 [debug] 22765#0: worker cycle  
2007/12/31 10:07:11 [debug] 22765#0: accept mutex locked  
2007/12/31 10:07:11 [debug] 22765#0: kevent timer: 60000, changes: 1

---

<div class="post-metadata">

**Author:** ![Jamey\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/5e9695/32.png) [@Jamey\_C](https://www.ruby-forum.com/u/Jamey_C)\
**Post date:** [December 23, 2007, 3:32pm UTC](https://www.ruby-forum.com/t/slow-file-upload-on-os-x-server/123874/6 "2007-12-23T15:32:10Z")

</div>

How slow is it?  
I use OS X and nginx as a frontend, but not to mongrel. File uploading  
works  
fine for me.

---

<div class="post-metadata">

**Author:** ![Jamey\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/5e9695/32.png) [@Jamey\_C](https://www.ruby-forum.com/u/Jamey_C)\
**Post date:** [January 1, 2008, 6:42pm UTC](https://www.ruby-forum.com/t/slow-file-upload-on-os-x-server/123874/7 "2008-01-01T18:42:35Z")

</div>

Jamey C. ha scritto:

> I have a rails app running on an OS X server, using nginx as the web  
> server, proxying to a mongrel cluster. File uploads from the user’s  
> browser are painfully slow when going through nginx, but if I target an  
> individual mongrel instance in the browser, the file upload is fast. I  
> have the latest mac ports version of nginx installed ( 0.54, I believe).
> 
> Any ideas?

> […]

Are you sure that it is “globally” slower?

nginx will first read the entire request body, and then will send the  
data to the proxy.

Regards Manlio P.
