五月综合激情婷婷六月,日韩欧美国产一区不卡,他扒开我内裤强吻我下面视频 ,无套内射无矿码免费看黄,天天躁,日日躁,狠狠躁

新聞動態(tài)

nginx優(yōu)化的六點方法

發(fā)布日期:2021-12-29 00:11 | 文章來源:源碼之家

一.優(yōu)化Nginx并發(fā)量

[root@proxy ~]# ab -n 2000 -c 2000 http://192.168.4.5/
Benchmarking 192.168.4.5 (be patient)
socket: Too many open files (24)    //提示打開文件數(shù)量過多

修改Nginx配置文件,增加并發(fā)量

[root@proxy ~]# vim /usr/local/nginx/conf/nginx.conf
.. ..
worker_processes 2;     //與CPU核心數(shù)量一致
events {
worker_connections 65535;  //每個worker最大并發(fā)連接數(shù)
use epoll;
}
.. ..
[root@proxy ~]# nginx -s reload

二.優(yōu)化Linux內核參數(shù)(最大文件數(shù)量)

[root@proxy ~]# ulimit -a      //查看所有屬性值
[root@proxy ~]# ulimit -Hn 100000    //設置硬限制(臨時規(guī)則)
[root@proxy ~]# ulimit -Sn 100000    //設置軟限制(臨時規(guī)則)
[root@proxy ~]# vim /etc/security/limits.conf
 .. ..
*    soft nofile   100000
*    hard nofile   100000
#該配置文件分4列,分別如下:
#用戶或組 硬限制或軟限制 需要限制的項目 限制的值

優(yōu)化后測試服務器并發(fā)量

[root@proxy ~]# ab -n 2000 -c 2000 http://192.168.4.5/

三.優(yōu)化Nginx數(shù)據(jù)包頭緩存

[root@proxy ~]# cat lnmp_soft/buffer.sh 
#!/bin/bash
URL=http://192.168.4.5/index.html?
for i in {1..5000}
do
 URL=${URL}v$i=$i
done
curl $URL        //經(jīng)過5000次循環(huán)后,生成一個長的URL地址欄
[root@proxy ~]# ./buffer.sh
.. ..
<center><h1>414 Request-URI Too Large</h1></center>  //提示頭部信息過大

修改Nginx配置文件,增加數(shù)據(jù)包頭部緩存大小

[root@proxy ~]# vim /usr/local/nginx/conf/nginx.conf
.. ..
http {
client_header_buffer_size 1k;  //默認請求包頭信息的緩存 
large_client_header_buffers 4 4k;  //大請求包頭部信息的緩存?zhèn)€數(shù)與容量
.. ..
}
[root@proxy ~]# nginx -s reload

四.對頁面進行壓縮處理

[root@proxy ~]# cat /usr/local/nginx/conf/nginx.conf
http {
.. ..
gzip on;       //開啟壓縮
gzip_min_length 1000;    //小文件不壓縮
gzip_comp_level 4;    //壓縮比率
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
         //對特定文件壓縮,類型參考mime.types
.. ..

五.服務器內存緩存

http { 
open_file_cache   max=2000 inactive=20s;
  open_file_cache_valid 60s;
  open_file_cache_min_uses 5;
  open_file_cache_errors off;
//設置服務器最大緩存2000個文件句柄,關閉20秒內無請求的文件句柄
//文件句柄的有效時間是60秒,60秒后過期
//只有訪問次數(shù)超過5次會被緩存
}

六.瀏覽器本地緩存靜態(tài)數(shù)據(jù)

[root@proxy ~]# vim /usr/local/nginx/conf/nginx.conf
server {
  listen  80;
  server_name localhost;
  location / {
   root html;
   index index.html index.htm;
  }
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
expires  30d;   //定義客戶端緩存時間為30天
}
}
[root@proxy ~]# cp /usr/share/backgrounds/day.jpg /usr/local/nginx/html
[root@proxy ~]# nginx -s reload

到此這篇關于nginx優(yōu)化的六點方法的文章就介紹到這了,更多相關nginx優(yōu)化內容請搜索本站以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持本站!

版權聲明:本站文章來源標注為YINGSOO的內容版權均為本站所有,歡迎引用、轉載,請保持原文完整并注明來源及原文鏈接。禁止復制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務器上建立鏡像,否則將依法追究法律責任。本站部分內容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學習參考,不代表本站立場,如有內容涉嫌侵權,請聯(lián)系alex-e#qq.com處理。

實時開通

自選配置、實時開通

免備案

全球線路精選!

全天候客戶服務

7x24全年不間斷在線

專屬顧問服務

1對1客戶咨詢顧問

在線
客服

在線客服:7*24小時在線

客服
熱線

400-630-3752
7*24小時客服服務熱線

關注
微信

關注官方微信
頂部