Bandwidth limit

The HTTP Bandwidth limit filter limits the size of data flow to the max bandwidth set in the limit_kbps when the request’s route, virtual host or filter chain has a bandwidth limit configuration.

If the bandwidth limit has been exhausted the filter stops further transfer until more bandwidth gets allocated according to the fill_interval (default is 50 milliseconds). If the connection buffer fills up with accumulated data then the source of data will have readDisable(true) set as described in the flow control doc.

Note

The token bucket is shared across all workers, thus the limits are applied per Envoy process.

Example configuration

Example filter configuration for a globally disabled bandwidth limiter but enabled for a specific route:

          "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
          codec_type: AUTO
          stat_prefix: ingress_http
          route_config:
            name: local_route
            virtual_hosts:
            - name: local_service
              domains: ["*"]
              routes:
              - match: {prefix: "/path/with/bandwidth/limit"}
                route: {cluster: service_protected_by_bandwidth_limit}
                typed_per_filter_config:
                  envoy.filters.http.bandwidth_limit:
                    "@type": type.googleapis.com/envoy.extensions.filters.http.bandwidth_limit.v3.BandwidthLimit
                    stat_prefix: bandwidth_limiter_custom_route
                    enable_mode: REQUEST_AND_RESPONSE
                    limit_kbps: 500
                    fill_interval: 0.1s
              - match: {prefix: "/"}
                route: {cluster: web_service}
          http_filters:
          - name: envoy.filters.http.bandwidth_limit
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.bandwidth_limit.v3.BandwidthLimit
              stat_prefix: bandwidth_limiter_default
          - name: envoy.filters.http.router
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
  clusters:
  - name: service_protected_by_bandwidth_limit
    type: STRICT_DNS
    lb_policy: ROUND_ROBIN
    load_assignment:
      cluster_name: service1
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: web_service
                port_value: 9000
  - name: web_service
    type: STRICT_DNS

Note that if this filter is configured as globally disabled and there are no virtual host or route level token buckets, no bandwidth limiting will be applied.

Statistics

The HTTP bandwidth limit filter outputs statistics in the <stat_prefix>.http_bandwidth_limit. namespace.

Name

Type

Description

request_enabled

Counter

Total number of request streams for which the bandwidth limiter was consulted

request_enforced

Counter

Total number of request streams for which the bandwidth limiter was enforced

request_pending

GAUGE

Number of request streams which are currently pending transfer in bandwidth limiter

request_incoming_size

GAUGE

Size in bytes of incoming request data to bandwidth limiter

request_allowed_size

GAUGE

Size in bytes of outgoing request data from bandwidth limiter

request_transfer_duration

HISTOGRAM

Total time (including added delay) it took for the request stream transfer

response_enabled

Counter

Total number of response streams for which the bandwidth limiter was consulted

response_enforced

Counter

Total number of response streams for which the bandwidth limiter was enforced

response_pending

GAUGE

Number of response streams which are currently pending transfer in bandwidth limiter

response_incoming_size

GAUGE

Size in bytes of incoming response data to bandwidth limiter

response_allowed_size

GAUGE

Size in bytes of outgoing response data from bandwidth limiter

response_transfer_duration

HISTOGRAM

Total time (including added delay) it took for the response stream transfer

Runtime

The HTTP bandwidth limit filter supports the following runtime settings:

The bandwidth limit filter can be runtime feature flagged via the enabled configuration field.