Nginx服务静态大文件 [英] Nginx Serving static large file

查看:249
本文介绍了Nginx服务静态大文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简单问题

http://mysite.com/bigFile.avi #此文件为800Mb

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

当我使用此链接并从浏览器下载bigFile.avi时, 我的Nginx服务器在下载会话期间跃升到100%CPU负载,静态内容,没有php. (正常的php脚本使用1-3%的CPU)

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)

我想知道这对我的服务器是否正常? 确实会消耗大量CPU来处理大文件吗?

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

(我什至在nginx配置中关闭了gzip,但差别不大)

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

推荐答案

由于nginx可以在将大型文件发送到客户端之前在磁盘中写入大文件,因此,如果站点要提供大型静态文件,则最好禁用此缓存文件,例如:

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;
}

这篇关于Nginx服务静态大文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆