Nginx sendfile作用
生活随笔
收集整理的這篇文章主要介紹了
Nginx sendfile作用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
sendfile位置
查看nginx.conf文件 標黃位置
#user nobody; worker_processes 1;#error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024; }http {include mime.types;default_type application/octet-stream;server_names_hash_bucket_size 128;#請求行+請求頭的標準大小client_header_buffer_size 16k;#請求行+請求頭的最大大小 4*16klarge_client_header_buffers 4 16k;#log_format main '$remote_addr - $remote_user [$time_local] "$request" '# '$status $body_bytes_sent "$http_referer" '# '"$http_user_agent" "$http_x_forwarded_for"';#access_log logs/access.log main;**sendfile on;**#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;# another virtual host using mix of IP-, name-, and port-based configuration##server {# listen 8000;# listen somename:8080;# server_name somename alias another.alias;# location / {# root html;# index index.html index.htm;# }#}#include vhosts.conf;#include vhosts/*.conf;# HTTPS server##server {# listen 443 ssl;# server_name localhost;# ssl_certificate cert.pem;# ssl_certificate_key cert.key;# ssl_session_cache shared:SSL:1m;# ssl_session_timeout 5m;# ssl_ciphers HIGH:!aNULL:!MD5;# ssl_prefer_server_ciphers on;# location / {# root html;# index index.html index.htm;# }#}server {listen 8085; server_name localhost dev.heating.com;location /man {proxy_pass http://127.0.0.1:8405/;proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-For $http_x_forwarded_for;}location /fs {proxy_pass http://127.0.0.1:8080/;proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-For $http_x_forwarded_for;}location / {root D:\heating\dist;index index.html index.htm;}} client_max_body_size 50m; }網絡文件傳輸
1.工作原理圖
2. 工作原理描述:
sendfile = off 時,應用程序讀取磁盤中的文件以字節流的形式從磁盤中加載文件,然后再將文件以字節流的形式復制到內核中。內核在把文件推送到NC。
sendfile = on 時,應用程序直接向內核發送指令,讓內核去讀文件。讀完文件內核直接推送給NC。只有一次復制操作,實現異步網絡IO形式。因此,性能會有很大的提升。
具體還要根據實際使用情況來配置sendfile。當讀取服務不能解析大量的文件時。還是建議將sendfile配置為off
總結
以上是生活随笔為你收集整理的Nginx sendfile作用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 反骨之Java是如何解决并发中的可见性问
- 下一篇: 【genius_platform软件平台