# Nginx file upload: server slows down terribly during upload

**URL:** <https://www.ruby-forum.com/t/nginx-file-upload-server-slows-down-terribly-during-upload/131619>\
**Category:** NGINX\
**Created:** [March 11, 2008, 10:50pm UTC](https://www.ruby-forum.com/t/nginx-file-upload-server-slows-down-terribly-during-upload/131619 "2008-03-11T22:50:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![matter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@matter](https://www.ruby-forum.com/u/matter)\
**Post date:** [March 11, 2008, 10:50pm UTC](https://www.ruby-forum.com/t/nginx-file-upload-server-slows-down-terribly-during-upload/131619/1 "2008-03-11T22:50:52Z")

</div>

I am using 2 Nginx worker processes (1024 connections). Nginx proxies  
the requests to 4 mongrel instances. I have noticed that during file  
uploads (files are approx. 10 MB each), the server(machine) slows down  
quite a lot even though ‘top’ command does not show any spikes in memory  
or CPU usage. Nginx is configured to send out static content. I suspect  
this is a problem with my Nginx setup because during uploads, all static  
content is served very slowly.

I wonder if anyone can give me any ideas why this might be happening?

Below are parts fron the nginx.conf I am using.

worker\_processes 4;  
events {  
worker\_connections 1024;  
}

http {  
include /etc/nginx/mime.types;  
default\_type application/octet-stream;

```
access_log /var/log/nginx/access.log;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain text/html text/css

```

application/x-javascript text/xml app  
lication/xml application/xml+rss text/javascript;

```
sendfile on;
tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay off;

```

Thanks!

---

<div class="post-metadata">

**Author:** ![matter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@matter](https://www.ruby-forum.com/u/matter)\
**Post date:** [March 11, 2008, 10:52pm UTC](https://www.ruby-forum.com/t/nginx-file-upload-server-slows-down-terribly-during-upload/131619/2 "2008-03-11T22:52:05Z")

</div>

Correction: I am using 2 worker processes and not 4, as the nginx.conf  
shows in my previous post.

---

<div class="post-metadata">

**Author:** ![matter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@matter](https://www.ruby-forum.com/u/matter)\
**Post date:** [March 12, 2008, 12:43am UTC](https://www.ruby-forum.com/t/nginx-file-upload-server-slows-down-terribly-during-upload/131619/3 "2008-03-12T00:43:17Z")

</div>

My suspicion would be IO load.

Nginx buffers the upload to a file on disk before then transfering the  
upload in full to mongrel (so there is a big read load at that point).  
Mongrel then writes the file to disk (writes conflicting with reads),  
then rails unpacks the file into its mime components (look in your  
temp directory), so more read and write load.

What does iostat or vmstat say? What is your IO subsystem like ? what  
does hdparm say, etc, etc.

Cheers

Dave

---

<div class="post-metadata">

**Author:** ![matter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@matter](https://www.ruby-forum.com/u/matter)\
**Post date:** [March 12, 2008, 1:03am UTC](https://www.ruby-forum.com/t/nginx-file-upload-server-slows-down-terribly-during-upload/131619/4 "2008-03-12T01:03:15Z")

</div>

It seems stupid but if you max out your upload speed, your download  
speed  
will be down to a minimum. If you start uploading a file and then open  
another website which you know is usually fast, is it slow again? Check  
to  
see if it is not your internet connection that is the problem rather  
than  
nginx+server.  
Kiril

---

<div class="post-metadata">

**Author:** ![matter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/97f17d/32.png) [@matter](https://www.ruby-forum.com/u/matter)\
**Post date:** [March 13, 2008, 9:28pm UTC](https://www.ruby-forum.com/t/nginx-file-upload-server-slows-down-terribly-during-upload/131619/5 "2008-03-13T21:28:37Z")

</div>

Thanks Dave, Kiril. I’m going to give your suggestions a try.
