Java常用中间件之 NGINX实现限流功能的官方文档说明(1)

    }

Directives

Syntax:语法limit_req zone=name [burst=number] [nodelay | delay=number];
Default: 默认
Context:内容(作用范围)httpserverlocation

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. By default, the maximum burst size is equal to zero. For example, the directives

设置共享内存区域和请求的最大突发大小。如果请求速率超过了区域配置的速率,则会延迟其处理,以便以定义的速率处理该请求。过多的请求将被延迟,直到其数量超过最大突发大小为止,在这种情况下,该请求将因错误而终止 。默认情况下,最大突发大小等于零。例如,指令

limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;

server {

location /search/ {
    limit_req zone=one burst=5;
}

allow not more than 1 request per second at an average, with bursts not exceeding 5 requests.

If delaying of excessive requests while requests are being limited is not desired, the parameter nodelay should be used:

平均每秒最多允许不超过1个请求,并且突发不超过5个请求。

如果不需要在限制请求时延迟过多的请求,则应使用nodelay参数:

limit_req zone=one burst=5 nodelay;

The delay parameter (1.15.7) specifies a limit at which excessive requests become delayed. Default value is zero, i.e. all excessive requests are delayed.

There could be several limit_req directives. For example, the following configuration will limit the processing rate of requests coming from a single IP address and, at the same time, the request processing rate by the virtual server:

delay参数(1.15.7),用于指定过多的请求延迟的限制。默认值为零,即所有多余的请求都会延迟。

可能有几个limit_req指令。例如,以下配置将限制来自单个IP地址的请求的处理速度,同时限制虚拟服务器的请求处理速度:

limit_req_zone $binary_remote_addr zone=perip:10m rate=1r/s; limit_req_zone $server_name zone=perserver:10m rate=10r/s; server { ... limit_req zone=perip burst=5 nodelay; limit_req zone=perserver burst=10; }

These directives are inherited from the previous configuration level if and only if there are no limit_req directives defined on the current level.

当且仅当limit_req当前级别上未定义任何指令时,这些指令才从先前的配置级别继承。

Syntax:limit_req_dry_run on | off;
Default:
limit_req_dry_run off;
Context:httpserverlocation

This directive appeared in version 1.17.1.

该指令出现在1.17.1版中

Enables the dry run mode. In this mode, requests processing rate is not limited, however, in the shared memory zone, the number of excessive requests is accounted as usual.

启用空运行模式。在这种模式下,请求处理速率不受限制,但是,在共享内存区域中,过多请求的数量将照常计算。

Syntax:limit_req_log_level info | notice | warn | error;
Default:
limit_req_log_level error;
Context:httpserverlocation

This directive appeared in version 0.8.18.

该指令出现在版本0.8.18中。

Sets the desired logging level for cases when the server refuses to process requests due to rate exceeding, or delays request processing. Logging level for delays is one point less than for refusals; for example, if “limit_req_log_level notice” is specified, delays are logged with the info level.

在服务器由于速率超出而拒绝处理请求或延迟请求处理的情况下,设置所需的日志记录级别。延迟的记录级别比拒绝的记录级别少一个等级;例如,如果limit_req_log_level notice指定“ ” ,则将延迟记录为该info级别。

Syntax:limit_req_status code;
Default:
limit_req_status 503;
Context:httpserverlocation

This directive appeared in version 1.3.15.

该指令出现在1.3.15版中。

Sets the status code to return in response to rejected requests.

设置被拒绝的请求而返回响应的状态代码。

Syntax:limit_req_zone key zone=name:size rate=rate [sync];
Default:
Context:http

Sets parameters for a shared memory zone that will keep states for various keys. In particular, the state stores the current number of excessive requests. The _key_ can contain text, variables, and their combination. Requests with an empty key value are not accounted.

设置共享内存区域的参数,该参数将保留各种键的状态。特别是,状态存储了当前过多请求的数量。该_key_可以包含文本,变量,他们的组合。具有空键值的请求不予考虑。

Prior to version 1.7.6, a  _key_ could contain exactly one variable.

在版本1.7.6之前,一个 _key_只包含一个变量。

Usage example:

用法示例:

最后

Java架构进阶面试及知识点文档笔记

这份文档共498页,其中包括Java集合,并发编程,JVM,Dubbo,Redis,Spring全家桶,MySQL,Kafka等面试解析及知识点整理

image

Java分布式高级面试问题解析文档

其中都是包括分布式的面试问题解析,内容有分布式消息队列,Redis缓存,分库分表,微服务架构,分布式高可用,读写分离等等!

image

互联网Java程序员面试必备问题解析及文档学习笔记

image

Java架构进阶视频解析合集

Java分布式高级面试问题解析文档

其中都是包括分布式的面试问题解析,内容有分布式消息队列,Redis缓存,分库分表,微服务架构,分布式高可用,读写分离等等!

[外链图片转存中…(img-HUUQ4d5s-1714364207334)]

互联网Java程序员面试必备问题解析及文档学习笔记

[外链图片转存中…(img-NUaU9lqu-1714364207334)]

Java架构进阶视频解析合集

本文已被CODING开源项目:【一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码】收录

  • 21
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值