15

I have a bigFile.avi which is 800MB and is at http://example.com/bigFile.avi.

When I use this link to download the bigFile.avi from the browser, my nginx server jumps to 100% CPU load during the download session with no static content nor PHP (normal PHP scripts use 1-3% CPU).

Is this normal for the server? Does it consume so much CPU to serve large files?

I have even tried turning off the gzip in the nginx config, but there is not much difference.

Unheilig
16.3k193 gold badges71 silver badges101 bronze badges
asked Sep 13, 2011 at 1:33

3 Answers 3

16

As nginx can write large files in disk before sending them to the client, it's often a good idea to disable this cache if the site is going to serve big static files, with something like:

location / {
 proxy_max_temp_file_size 0;
}
answered Mar 24, 2014 at 9:46
Sign up to request clarification or add additional context in comments.

1 Comment

When trying to download a large file (> 2GB), progress always stopped at about 50%. This solved it!
9

Take a look at these articles

I will admit that some of that is beyond me. But in short they suggest disabling sendfile, enabling aio, and increasing your output buffers if you're sending large (>4MB) files. What I took away is that most default server configs assume many small files will be sent, rather than few or many large files. These two different scenarios can require some very different configs to work efficiently.

answered Sep 13, 2011 at 2:04

Comments

1

Nginx's own website has a lot of good information on how to optimize your web-server for (large) static files hosting.

Personally I'm using the following configuration (taken straight from the nginx documentation).

sendfile on;
sendfile_max_chunk 1m;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
answered Aug 21, 2022 at 23:18

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.