The documentation you are viewing is for Dapr v1.8 which is an older version of Dapr. For up-to-date documentation, see the latest version.
速率限制
The rate limit HTTP middleware allows restricting the maximum number of allowed HTTP requests per second. 速率限制可以保护您的应用程序免受拒绝服务(DOS)攻击。 DOS攻击可以由恶意的第三方发起,也可以由你的软件中的错误发起(也就是 “友军 “DOS攻击)。
配置
根据下述定义,请求正文转换为大写字母:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: ratelimit
spec:
type: middleware.http.ratelimit
version: v1
metadata:
- name: maxRequestsPerSecond
value: 10
元数据字段规范
字段 | 详情 | Example |
---|---|---|
maxRequestsPerSecond | 按远程IP和路径每秒的最大请求。 需要考虑的是, 限制在每个 Dapr sidecar中独立执行,而不是群集 | 10 |
一旦达到上限,请求将返回 HTTP Status code 429: Too Many Requests。
Alternatively, the max concurrency setting can be used to rate limit applications and applies to all traffic regardless of remote IP or path.
Dapr配置
To be applied, the middleware must be referenced in configuration. See middleware pipelines.
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
spec:
httpPipeline:
handlers:
- name: ratelimit
type: middleware.http.ratelimit
相关链接
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.