From 49af57d546b5e2fd5aaa9fcd43d09060b9682c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Fri, 13 Sep 2019 14:20:04 +0200 Subject: Implement backpressure on cowboy_req:stream_body This should limit the amount of memory that Cowboy is using when a handler is sending data much faster than the network. The new max_stream_buffer_size is a soft limit and only has an effect when the cowboy_stream_h handler is used. --- doc/src/manual/cowboy_http2.asciidoc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/src/manual/cowboy_http2.asciidoc b/doc/src/manual/cowboy_http2.asciidoc index 19271d4..e899289 100644 --- a/doc/src/manual/cowboy_http2.asciidoc +++ b/doc/src/manual/cowboy_http2.asciidoc @@ -31,6 +31,7 @@ opts() :: #{ max_encode_table_size => non_neg_integer(), max_frame_size_received => 16384..16777215, max_frame_size_sent => 16384..16777215 | infinity, + max_stream_buffer_size => non_neg_integer(), max_stream_window_size => 0..16#7fffffff, preface_timeout => timeout(), proxy_header => boolean(), @@ -136,6 +137,12 @@ following the client's advertised maximum. Note that actual frame sizes may be lower than the limit when there is not enough space left in the flow control window. +max_stream_buffer_size (8000000):: + +Maximum stream buffer size in bytes. This is a soft limit used +to apply backpressure to handlers that send data faster than +the HTTP/2 connection allows. + max_stream_window_size (16#7fffffff):: Maximum stream window size in bytes. This is used as an upper bound @@ -186,7 +193,9 @@ too many `WINDOW_UPDATE` frames. `max_connection_window_size`, `max_stream_window_size`, `stream_window_margin_size` and `stream_window_update_threshold` to configure - behavior on sending WINDOW_UPDATE frames. + behavior on sending WINDOW_UPDATE frames, and + `max_stream_buffer_size` to apply backpressure + when sending data too fast. * *2.6*: The `proxy_header` and `sendfile` options were added. * *2.4*: Add the options `initial_connection_window_size`, `initial_stream_window_size`, `max_concurrent_streams`, -- cgit v1.2.3