nginx limit 限流
阿新 • • 發佈:2019-02-11
超過每秒1次的請求就返回503
Sets the shared memory zone and the maximum burst size of requests. If the requests rate exceeds the rate configured for a zone, their processing is delayed such that requests are processed at a defined rate. Excessive requests are delayed until their number exceeds the maximum burst size in which case the request is terminated with an error 503 (Service Temporarily Unavailable). By default, the maximum burst size is equal to zero. For example, the directives
http {
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
...
server {
...
location /search/ {
limit_req zone=one burst=5; #這裡是說每次請求最大超過5次就返回503
}
我自己做了個測試
http模組裡面配置的不會影響整個nginx
限流的結果是日誌回記錄503的返回值,很多非200就是證據,日誌我也看了,就不截圖了
不限流的來一漲