(1) sendfile 参数用于开启文件的高效传输模式,该参数实际上是**了 sendfile() 功能,sendfile() 是作用于两个文件描述符之间的数据拷贝函数,这个拷贝操作是在内核之中的,被称为 “零拷贝” ,sendfile() 比 read 和 write 函数要高效得多,因为 read 和 write 函数要把数据拷贝到应用层再进行操作

(2) tcp_nopush 参数用于** Linux 上的 TCP_CORK socket 选项,此选项仅仅当开启 sendfile 时才生效,tcp_nopush 参数可以允许把 http response header 和文件的开始部分放在一个文件里发布,以减少网络报文段的数量

cat /usr/local/nginx/conf/nginx.conf

……

http {

include mime.types;

server_names_hash_bucket_size 512;

default_type application/octet-stream;

sendfile on; # 开启文件的高效传输模式

tcp_nopush on; # ** TCP_CORK socket 选择

tcp_nodelay on; #数据在传输的过程中不进缓存

keepalive_timeout 65;

server_tokens off;

include vhosts/*.conf;

}

作者简介:
陈志珂(头条号:强扭的瓜不好吃),公众号“铅笔学园”运维内容合作作者之一。目前就职于中国最大的安卓应用软件公司,任高级工程师,现在公司任php开发工程师,python开发工程师,高级运维工程师。
铅笔学园:IT资源分享|知识分享,做初级程序员的指明灯
nginx 开启高效文件传输模式

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2022-01-04
  • 2021-05-17
  • 2021-09-15
  • 2021-04-01
猜你喜欢
  • 2021-06-25
  • 2021-09-15
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2021-05-25
相关资源
相似解决方案