Search code examples
istioenvoyproxy

how to use retries for local rate limiter envoy requests


I want to set up a retry policy for requests that have been restricted by the local rate limiter. The documentation states that you must add envoy-ratelimited to the retry_on field.

But somehow it doesn't work.I do not see that the statistics on retry in the admin panel increases, and the response time is instantaneous despite the 4 maximum attempts like:

enter image description here

My configuration is

              routes:
              - match:
                  prefix: "/app"
                route:
                  host_rewrite_literal: app
                  prefix_rewrite: "/"
                  timeout: 15s
                  cluster: app
                  retry_policy:
                    retry_on: envoy-ratelimited
                    num_retries: 4
                typed_per_filter_config:
                  envoy.filters.http.local_ratelimit:
                    "@type": type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit
                    stat_prefix: app_ratelimit
                    token_bucket:
                      max_tokens: 5
                      tokens_per_fill: 5
                      fill_interval: 5s
                    filter_enabled:
                      runtime_key: local_rate_limit_enabled
                      default_value:
                        numerator: 100
                        denominator: HUNDRED
                    filter_enforced:
                      runtime_key: local_rate_limit_enforced
                      default_value:
                        numerator: 100
                        denominator: HUNDRED

Solution

  • At the moment, no any possible way.

    You can only use the two listeners system proposed below:

    Retry listener -> rate limit listener -> upstream

    You need to configure a local rate limiter on the listener that sends the request to the upstream. Then if request from this listener will be limited by local rate limiter, then retry listener will retry this one (You need retry listener to be configured for 4xx retry_on)