<p>I am trying to implement rate limiting feature to my AKS using nginx ingress rate limiting. I have just provided <code>limit-rps:10</code> in nginx ingress resource. Still, i dont see expected behavior which is rps * default burst rate. Could somebody help on how rate limiting works in nginx and how to set the configuration in nginx resource?</p>
<pre><code>kind: Ingress
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {&quot;apiVersion&quot;:&quot;extensions/v1beta1&quot;,&quot;kind&quot;:&quot;Ingress&quot;,&quot;metadata&quot;:{&quot;annotations&quot;:{&quot;kubernetes.io/ingress.class&quot;:&quot;nginx&quot;,&quot;nginx.ingress.kubernetes.io/limit-rpm&quot;:&quot;1&quot;,&quot;nginx.ingress.kubernetes.io/proxy-body-size&quot;:&quot;30m&quot;,&quot;nginx.ingress.kubernetes.io/rewrite-target&quot;:&quot;/$2&quot;,&quot;nginx.ingress.kubernetes.io/ssl-redirect&quot;:&quot;false&quot;},&quot;name&quot;:&quot;hop-ingress&quot;,&quot;namespace&quot;:&quot;default&quot;},&quot;spec&quot;:{&quot;rules&quot;:[{&quot;http&quot;:{&quot;paths&quot;:[{&quot;backend&quot;:{&quot;serviceName&quot;:&quot;example-service&quot;,&quot;servicePort&quot;:80},&quot;path&quot;:&quot;/&quot;}]}}]}}
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/limit-connections: &quot;1&quot;
    nginx.ingress.kubernetes.io/limit-rps: &quot;1&quot;
    nginx.ingress.kubernetes.io/proxy-body-size: 30m
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;false&quot;
  creationTimestamp: &quot;2021-08-13T13:33:12Z&quot;
  generation: 2
  name: hop-ingress
  namespace: default
  resourceVersion: &quot;21201898&quot;
  selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/hop-ingress
  uid: 574f4cf5-6b66-414f-ba2c-3c36c9d62ef0
spec:
  rules:
  - http:
      paths:
      - backend:
          serviceName: example-service
          servicePort: 80
        path: /
        pathType: ImplementationSpecific
  - http:
      paths:
      - backend:
          serviceName: productpage
          servicePort: 9080
        path: /productpage(/|$)(.*)
        pathType: ImplementationSpecific
status:
  loadBalancer:
    ingress:
    - ip: 13.71.57.131
</code></pre>

<p><code>limit-rps</code> is a <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#rate-limiting" rel="nofollow noreferrer">local rate limit settings</a> that is applied on a specific ingress object rather than in a config map provided to the ingress controller.</p>
<p>It will limit the number of requests per second from an IP adress:</p>
<blockquote>
<p>nginx.ingress.kubernetes.io/limit-rps: number of requests accepted
from a given IP each second. The burst limit is set to this limit
multiplied by the burst multiplier, the default multiplier is 5. When
clients exceed this limit, limit-req-status-code default: 503 is
returned.</p>
</blockquote>
<p>Please se below for a dummy example. As you can see <code>nginx.ingress.kubernetes.io/limit-rps: 10</code> is added under <code>metadata.annotations</code> on the ingress object</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: minimal-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/limit-rps: 10
spec:
  rules:
  - http:
      paths:
      - path: /testpath
        pathType: Prefix
        backend:
          service:
            name: test
            port:
              number: 80
</code></pre>
<p>It is possible to apply <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#global-rate-limiting" rel="nofollow noreferrer">global rate limiting</a> as well, please see the manual for details</p>
