How do I configure flow control?

Flow control may cause problems where Envoy is using non-streaming L7 filters, and request or response bodies exceed the L7 buffer limits. For requests where the body must be buffered and exceeds the configured limits, Envoy will serve a 413 to the user and increment the downstream_rq_too_large metric. On the response path if the response body must be buffered and exceeds the limit, Envoy will increment the rs_too_large metric and either disconnect mid-response (if headers have already been sent downstream) or send a 500 response.

There are three knobs for configuring Envoy flow control: listener limits, cluster limits and http2 stream limits

The listener limits apply to how much raw data will be read per read() call from downstream, as well as how much data may be buffered in userspace between Envoy and downstream.

The listener limits are also propogated to the HttpConnectionManager, and applied on a per-stream basis to HTTP/1.1 L7 buffers described below. As such they limit the size of HTTP/1 requests and response bodies that can be buffered. For HTTP/2, as many streams can be multiplexed over one TCP connection, the L7 and L4 buffer limits can be tuned separately, and the configuration option http2 stream limits is applied to all of the L7 buffers. Note that for both HTTP/1 and HTTP/2 Envoy can and will proxy arbitrarily large bodies on routes where all L7 filters are streaming, but many filters such as the transcoder or buffer filters require the full HTTP body to be buffered, so limit the request and response size based on the listener limit.

The cluster limits affect how much raw data will be read per read() call from upstream, as well as how much data may be buffered in userspace between Envoy and upstream.

The following code block shows how to adjust all three fields mentioned above, though generally the only one which needs to be amended is the listener per_connection_buffer_limit_bytes

  1. static_resources:
  2. listeners:
  3. name: http
  4. address:
  5. socket_address:
  6. address: '::1'
  7. portValue: 0
  8. filter_chains:
  9. filters:
  10. name: envoy.filters.network.http_connection_manager
  11. typed_config:
  12. "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
  13. http2_protocol_options:
  14. initial_stream_window_size: 65535
  15. route_config: {}
  16. codec_type: HTTP2
  17. http_filters: []
  18. stat_prefix: config_test
  19. per_connection_buffer_limit_bytes: 1024
  20. clusters:
  21. name: cluster_0
  22. connect_timeout: 5s
  23. per_connection_buffer_limit_bytes: 1024
  24. load_assignment:
  25. cluster_name: some_service
  26. endpoints:
  27. - lb_endpoints:
  28. - endpoint:
  29. address:
  30. socket_address:
  31. address: ::1
  32. port_value: 46685