Rate limiting inside kubernetes cluster
Solution 1:
It is possible to use Circuit Breaker in istio (kubernetes addon), which can be achieved by creating traffic policy connection pools with istio destinationrule
objects.
According to istio documentation:
Circuit breakers
Circuit breakers are another useful mechanism Istio provides for creating resilient microservice-based applications. In a circuit breaker, you set limits for calls to individual hosts within a service, such as the number of concurrent connections or how many times calls to this host have failed. Once that limit has been reached the circuit breaker “trips” and stops further connections to that host. Using a circuit breaker pattern enables fast failure rather than clients trying to connect to an overloaded or failing host.
As circuit breaking applies to “real” mesh destinations in a load balancing pool, you configure circuit breaker thresholds in destination rules, with the settings applying to each individual host in the service. The following example limits the number of concurrent connections for the
reviews
service workloads of the v1 subset to 100:apiVersion: networking.istio.io/v1alpha3 kind: DestinationRule metadata: name: reviews spec: host: reviews subsets: - name: v1 labels: version: v1 trafficPolicy: connectionPool: tcp: maxConnections: 100
You can find out more about creating circuit breakers in Circuit Breaking.