<p>I have spring boot service which is running on distributed VMs, but I want to move that service to Kubernetes. Previously we had spring cloud gateway configured for request limiter across those 4 VMs, but now with Kubernetes, my application will be auto-scalable.</p>

<p>In that case, how can I limit the requests given that, Kubernetes could increase or decrease the pods based on traffic? How can I maintain the state of the incoming traffic but still keep my service stateless?</p>

mangoman
<p>Essentially, you can do rate limiting by fronting your application with a proxy. (nginx, haproxy, etc). More specifically you can use a <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer">Kubernetes Ingress</a>. More specifically you can use the <a href="https://github.com/kubernetes/ingress-nginx" rel="nofollow noreferrer">nginx ingress controller</a> and the can use something like <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#limit-rate" rel="nofollow noreferrer">limit rate</a> in the ConfigMap or <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#rate-limiting" rel="nofollow noreferrer">rate limiting</a> through annotations in the ingress.</p>
