0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 20:30:23 +00:00

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.
This commit is contained in:
Loïc Hoguin 2019-09-13 14:20:04 +02:00
parent 4427108b69
commit 49af57d546
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
6 changed files with 91 additions and 25 deletions

View file

@ -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`,