0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 20:50:24 +00:00

Add hibernate option to cowboy_http and cowboy_http2

When enabled the connection process will automatically hibernate.
Because hibernation triggers GC, this can be used as a way to
keep memory usage lower, at the cost of performance.
This commit is contained in:
Loïc Hoguin 2025-02-07 16:57:58 +01:00
parent d3f6bda38b
commit 0f257d06b6
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
6 changed files with 103 additions and 33 deletions

View file

@ -21,6 +21,7 @@ opts() :: #{
chunked => boolean(),
connection_type => worker | supervisor,
dynamic_buffer => false | {pos_integer(), pos_integer()},
hibernate => boolean(),
http10_keepalive => boolean(),
idle_timeout => timeout(),
inactivity_timeout => timeout(),
@ -87,6 +88,10 @@ The dynamic buffer size functionality can be disabled by
setting this option to `false`. Cowboy will also disable
it by default when the `buffer` transport option is configured.
hibernate (false)::
Whether the connection process will hibernate automatically.
http10_keepalive (true)::
Whether keep-alive is enabled for HTTP/1.0 connections.
@ -179,7 +184,7 @@ Ordered list of stream handlers that will handle all stream events.
== Changelog
* *2.13*: The `active_n` default value was changed to `1`.
* *2.13*: The `dynamic_buffer` option was added.
* *2.13*: The `dynamic_buffer` and `hibernate` options were added.
* *2.11*: The `reset_idle_timeout_on_send` option was added.
* *2.8*: The `active_n` option was added.
* *2.7*: The `initial_stream_flow_size` and `logger` options were added.

View file

@ -25,6 +25,7 @@ opts() :: #{
enable_connect_protocol => boolean(),
goaway_initial_timeout => timeout(),
goaway_complete_timeout => timeout(),
hibernate => boolean(),
idle_timeout => timeout(),
inactivity_timeout => timeout(),
initial_connection_window_size => 65535..16#7fffffff,
@ -122,6 +123,10 @@ goaway_complete_timeout (3000)::
Time in ms to wait for ongoing streams to complete before closing the connection
during a graceful shutdown.
hibernate (false)::
Whether the connection process will hibernate automatically.
idle_timeout (60000)::
Time in ms with no data received before Cowboy closes the connection.
@ -302,7 +307,7 @@ too many `WINDOW_UPDATE` frames.
== Changelog
* *2.13*: The `active_n` default value was changed to `1`.
* *2.13*: The `dynamic_buffer` option was added.
* *2.13*: The `dynamic_buffer` and `hibernate` options were added.
* *2.11*: Websocket over HTTP/2 is now considered stable.
* *2.11*: The `reset_idle_timeout_on_send` option was added.
* *2.11*: Add the option `max_cancel_stream_rate` to protect