mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 20:50:24 +00:00
Use active,N
This reduces the number of times we need to ask for more packets, and as a result we get a fairly large boost in performance, especially with HTTP/1.1. Unfortunately this makes Cowboy require at least Erlang/OTP 21.3+ because the ssl application did not have active,N. For simplicity the version required will be Erlang/OTP 22+. In addition this change improves hibernate handling in cowboy_websocket. Hibernate will now work for HTTP/2 transport as well, and stray or unrelated messages will no longer cancel hibernate (the process will handle the message and go back into hibernation). Thanks go to Stressgrid for benchmarking an early version of this commit: https://stressgrid.com/blog/cowboy_performance_part_2/
This commit is contained in:
parent
592029070d
commit
db0d6f8d25
9 changed files with 208 additions and 65 deletions
|
@ -17,6 +17,7 @@ as a Ranch protocol.
|
|||
[source,erlang]
|
||||
----
|
||||
opts() :: #{
|
||||
active_n => pos_integer(),
|
||||
chunked => boolean(),
|
||||
connection_type => worker | supervisor,
|
||||
http10_keepalive => boolean(),
|
||||
|
@ -51,6 +52,14 @@ Ranch functions `ranch:get_protocol_options/1` and
|
|||
|
||||
The default value is given next to the option name:
|
||||
|
||||
active_n (100)::
|
||||
|
||||
The number of packets Cowboy will request from the socket at once.
|
||||
This can be used to tweak the performance of the server. Higher
|
||||
values reduce the number of times Cowboy need to request more
|
||||
packets from the port driver at the expense of potentially
|
||||
higher memory being used.
|
||||
|
||||
chunked (true)::
|
||||
|
||||
Whether chunked transfer-encoding is enabled for HTTP/1.1 connections.
|
||||
|
@ -151,6 +160,7 @@ Ordered list of stream handlers that will handle all stream events.
|
|||
|
||||
== Changelog
|
||||
|
||||
* *2.8*: The `active_n` option was added.
|
||||
* *2.7*: The `initial_stream_flow_size` and `logger` options were added.
|
||||
* *2.6*: The `chunked`, `http10_keepalive`, `proxy_header` and `sendfile` options were added.
|
||||
* *2.5*: The `linger_timeout` option was added.
|
||||
|
|
|
@ -17,6 +17,7 @@ as a Ranch protocol.
|
|||
[source,erlang]
|
||||
----
|
||||
opts() :: #{
|
||||
active_n => pos_integer(),
|
||||
connection_type => worker | supervisor,
|
||||
connection_window_margin_size => 0..16#7fffffff,
|
||||
connection_window_update_threshold => 0..16#7fffffff,
|
||||
|
@ -59,6 +60,14 @@ Ranch functions `ranch:get_protocol_options/1` and
|
|||
|
||||
The default value is given next to the option name:
|
||||
|
||||
active_n (100)::
|
||||
|
||||
The number of packets Cowboy will request from the socket at once.
|
||||
This can be used to tweak the performance of the server. Higher
|
||||
values reduce the number of times Cowboy need to request more
|
||||
packets from the port driver at the expense of potentially
|
||||
higher memory being used.
|
||||
|
||||
connection_type (supervisor)::
|
||||
|
||||
Whether the connection process also acts as a supervisor.
|
||||
|
@ -226,6 +235,7 @@ too many `WINDOW_UPDATE` frames.
|
|||
|
||||
== Changelog
|
||||
|
||||
* *2.8*: The `active_n` option was added.
|
||||
* *2.7*: Add the options `connection_window_margin_size`,
|
||||
`connection_window_update_threshold`,
|
||||
`max_connection_window_size`, `max_stream_window_size`,
|
||||
|
|
|
@ -198,6 +198,7 @@ Cowboy does it automatically for you.
|
|||
[source,erlang]
|
||||
----
|
||||
opts() :: #{
|
||||
active_n => pos_integer(),
|
||||
compress => boolean(),
|
||||
deflate_opts => cow_ws:deflate_opts()
|
||||
idle_timeout => timeout(),
|
||||
|
@ -221,6 +222,16 @@ init(Req, State) ->
|
|||
|
||||
The default value is given next to the option name:
|
||||
|
||||
active_n (100)::
|
||||
|
||||
The number of packets Cowboy will request from the socket at once.
|
||||
This can be used to tweak the performance of the server. Higher
|
||||
values reduce the number of times Cowboy need to request more
|
||||
packets from the port driver at the expense of potentially
|
||||
higher memory being used.
|
||||
+
|
||||
This option does not apply to Websocket over HTTP/2.
|
||||
|
||||
compress (false)::
|
||||
|
||||
Whether to enable the Websocket frame compression
|
||||
|
@ -274,6 +285,7 @@ normal circumstances if necessary.
|
|||
|
||||
== Changelog
|
||||
|
||||
* *2.8*: The `active_n` option was added.
|
||||
* *2.7*: The commands based interface has been documented.
|
||||
The old interface is now deprecated.
|
||||
* *2.7*: The command `shutdown_reason` was introduced.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue