nginx 和php连接数,nginx限制ip连接数和带宽
搜索熱詞
今天有個人問我,Nginx怎么限制ip連接數,突然想不起來了,年齡大了,腦子不怎么好使了。還要看一下配置才想起了。那個人又問我,你測試過的嗎?一下子把我問蒙了,我真沒測試過了,也不知道啟作用了沒有。下面我做了一下測試。以前用apache的時候到是做過測試,apache怎么限制ip數,請參考:
1,配置Nginx.conf
http{
.............
limit_zone?? one? $binary_remote_addr? 10m;? //我記得默認配置就有,只不過是注釋掉了,如果沒有加一下
..............
server{
.................
location {
.........
limit_conn one 20;????????? //連接數限制
limit_rate 500k;??????????? //帶寬限制
........
}
.................
}
.............
}
[root@localhost Nginx]# /etc/init.d/Nginx reload //重新加載
2,測試限制ip連接數
[root@localhost Nginx]#? webbench -c 100 -t 2 http://127.0.0.1/index.PHP
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004,GPL Open Source Software.
Benchmarking: GET http://127.0.0.1/index.PHP
100 clients,running 2 sec.
Speed=429959 pages/min,2758544 bytes/sec.
Requests: 14332 susceed,0 Failed.
[root@localhost Nginx]# cat /var/log/Nginx/access.log|grep 503 |more?? //這樣的數據有很多,最好加個more或者less
127.0.0.1 - - [25/Apr/2012:17:52:21 +0800] "GET /index.PHP HTTP/1.0" 503 213 "-" "WebBench 1.5" -
127.0.0.1 - - [25/Apr/2012:17:52:21 +0800] "GET /index.PHP HTTP/1.0" 503 213 "-" "WebBench 1.5" -
127.0.0.1 - - [25/Apr/2012:17:52:21 +0800] "GET /index.PHP HTTP/1.0" 503 213 "-" "WebBench 1.5" -
127.0.0.1 - - [25/Apr/2012:17:52:21 +0800] "GET /index.PHP HTTP/1.0" 503 213 "-" "WebBench 1.5" -
127.0.0.1 - - [25/Apr/2012:17:52:21 +0800] "GET /index.PHP HTTP/1.0" 503 213 "-" "WebBench 1.5" -
127.0.0.1 - - [25/Apr/2012:17:52:21 +0800] "GET /index.PHP HTTP/1.0" 503 213 "-" "WebBench 1.5" -
127.0.0.1 - - [25/Apr/2012:17:52:21 +0800] "GET /index.PHP HTTP/1.0" 503 213 "-" "WebBench 1.5" -
127.0.0.1 - - [25/Apr/2012:17:52:21 +0800] "GET /index.PHP HTTP/1.0" 503 213 "-" "WebBench 1.5" -
..............................................................................................
通過以上測試,可以得出限制ip連接數是沒有問題的,但是限制帶寬看不出來,說實話這個不好測試,所以就沒測試了。
總結
以上是編程之家為你收集整理的nginx限制ip連接數和帶寬全部內容,希望文章能夠幫你解決nginx限制ip連接數和帶寬所遇到的程序開發問題。
如果覺得編程之家網站內容還不錯,歡迎將編程之家網站推薦給程序員好友。
本圖文內容來源于網友網絡收集整理提供,作為學習參考使用,版權屬于原作者。
總結
以上是生活随笔為你收集整理的nginx 和php连接数,nginx限制ip连接数和带宽的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php dimage加上域名,PHP全功
- 下一篇: apache不能解析php文件_Web中