Nginx Serving static large file

2019-04-04 15:30发布

Simple question

http://mysite.com/bigFile.avi #this file is 800Mb

when I use this link and download the bigFile.avi from my browser, My Nginx server jumps to 100%CPU load during the download session, static content, no php. (normal php scripts uses 1-3% CPU)

I wonder if this is normal for my server? It does consume so much CPU to serve large files?

(i even turn off the gzip in the nginx config, but not much difference)

2条回答
Luminary・发光体
2楼-- · 2019-04-04 16:04

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.

查看更多
The star\"
3楼-- · 2019-04-04 16:10

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;
}
查看更多
登录 后发表回答