nginx limit 限流

超过每秒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就是证据,日志我也看了,就不截图了

nginx limit 限流_第1张图片

不限流的来一涨
nginx limit 限流_第2张图片

你可能感兴趣的:(nginx)