简体   繁体   English

Nginx-Ingress-Controller 限制部署的 rps 数量

[英]Nginx-Ingress-Controller limit number of rps to deployment

I am having issues serving data under high load and would like to return a 503 if the total rps to a specific deployment exceeds a certain number.我在高负载下提供数据时遇到问题,如果特定部署的总 rps 超过一定数量,我想返回 503。 I was playing around with their rate limiting but that limits per client.我正在玩他们的速率限制,但每个客户端都有限制。

Thanks!谢谢!

Simpler approach, I would try, would be to limit the resources (CPU and Memory) for that deployment.我会尝试更简单的方法是限制该部署的资源(CPU 和内存)。 You can also separate the ingress controller for that service and limit resources for that as well.您还可以为该服务分离入口 controller 并限制该服务的资源。

Alternatively service meshes provide more customizations, for example istio provides ConnectionPoolSettings for DestinationRule objects that can serve similar purpose.或者,服务网格提供更多自定义,例如istio为可以服务于类似目的的DestinationRule对象提供ConnectionPoolSettings

Additionally, there is also an experimental feature of traffic shaping that might be helpful but that requires updating your CNI configuration.此外,还有一个流量整形的实验性功能可能会有所帮助,但需要更新您的 CNI 配置。


For reference: @Dylan figured out that limit_req_zone Nginx configuration can be used with $host to achieve this as well.供参考:@Dylan 发现limit_req_zone Nginx 配置也可以与$host一起使用来实现此目的。 In order to do this, (1) update your nginx ingress controller config map and add the http-snippet为此,(1) 更新您的 nginx 入口 controller 配置 map 并添加http-snippet

data:
  http-snippet: |
    limit_req_zone $host zone=queue:10m rate=1r/s;

You may have to restart your controller pods to pick up the new configuration.您可能需要重新启动 controller pod 以获取新配置。 (2) Apply the configuration to the Ingress using configuration-snippet : (2) 使用configuration-snippet将配置应用到 Ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/configuration-snippet: |
      limit_req zone=queue burst=12 delay=8;
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM