aboutsummaryrefslogtreecommitdiffstats
path: root/doc/src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2025-08-21 18:09:42 +0200
committerLoïc Hoguin <[email protected]>2025-09-15 13:09:23 +0200
commit8da6ca11e8ea4e93def78bd0299decd6f409bc43 (patch)
treee897bf997175a113e02acb2b7f4c179c7528aeb4 /doc/src
parenta8c717718a3f4dd7b4bc67fe7bebe3a4e7a7ed74 (diff)
downloadcowboy-8da6ca11e8ea4e93def78bd0299decd6f409bc43.tar.gz
cowboy-8da6ca11e8ea4e93def78bd0299decd6f409bc43.tar.bz2
cowboy-8da6ca11e8ea4e93def78bd0299decd6f409bc43.zip
New data delivery mechanism for HTTP/2+ Websocketdirect-data_delivery-for-h2-websocket
A new data_delivery mechanism called 'relay' has been added. It bypasses stream handlers (and the buffering in cowboy_stream_h) and sends the data directly to the process implementing Websocket (and should work for other similar protocols like HTTP/2 WebTransport). Flow control in HTTP/2 is maintained in a simpler way, via a configured flow value that is used to maintain the window to a reasonable value when data is received. The 'relay' data_delivery has been implemented for both HTTP/2 and HTTP/3. It has not been implemented for HTTP/1.1 since switching protocol there overrides the connection process. HTTP/2 Websocket is now better tested. A bug was fixed with the 'stream_handlers' data_delivery where active mode would not be reenabled if it was disabled at some point. The Websocket performance suite has been updated to include tests that do not use Gun. Websocket modules used by the performance suite use the 'relay' data_delivery now. Performance is improved significantly with 'relay', between 10% and 20% faster. HTTP/2 Websocket performance is not on par with HTTP/1.1 still, but the remaining difference is thought to be from the HTTP/2 overhead and flow control.
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/manual/cowboy_websocket.asciidoc38
1 files changed, 30 insertions, 8 deletions
diff --git a/doc/src/manual/cowboy_websocket.asciidoc b/doc/src/manual/cowboy_websocket.asciidoc
index 319dbae..f30ffca 100644
--- a/doc/src/manual/cowboy_websocket.asciidoc
+++ b/doc/src/manual/cowboy_websocket.asciidoc
@@ -200,14 +200,16 @@ Cowboy does it automatically for you.
[source,erlang]
----
opts() :: #{
- active_n => pos_integer(),
- compress => boolean(),
- deflate_opts => cow_ws:deflate_opts()
- dynamic_buffer => false | {pos_integer(), pos_integer()},
- idle_timeout => timeout(),
- max_frame_size => non_neg_integer() | infinity,
- req_filter => fun((cowboy_req:req()) -> map()),
- validate_utf8 => boolean()
+ active_n => pos_integer(),
+ compress => boolean(),
+ data_delivery => stream_handlers | relay,
+ data_delivery_flow => pos_integer(),
+ deflate_opts => cow_ws:deflate_opts(),
+ dynamic_buffer => false | {pos_integer(), pos_integer()},
+ idle_timeout => timeout(),
+ max_frame_size => non_neg_integer() | infinity,
+ req_filter => fun((cowboy_req:req()) -> map()),
+ validate_utf8 => boolean()
}
----
@@ -241,6 +243,22 @@ Whether to enable the Websocket frame compression
extension. Frames will only be compressed for the
clients that support this extension.
+data_delivery (stream_handlers)::
+
+HTTP/2+ only. Determines how data will be delivered
+to the Websocket session process. `stream_handlers`
+is the default and makes data go through stream
+handlers. `relay` is a faster method introduced in
+Cowboy 2.14 and sends data directly. `relay` is
+intended to become the default in Cowboy 3.0.
+
+data_delivery_flow (pos_integer())::
+
+When the `relay` data delivery method is used,
+this value may be used to decide how much the
+flow control window should be for the Websocket
+stream. Currently only applies to HTTP/2.
+
deflate_opts (#{})::
Configuration for the permessage-deflate Websocket
@@ -299,6 +317,10 @@ normal circumstances if necessary.
== Changelog
+* *2.14*: The `data_delivery` and `data_delivery_flow` options
+ were added. The `relay` data delivery mechanism
+ provides a better way of forwarding data to
+ HTTP/2+ Websocket session processes.
* *2.13*: The `active_n` default value was changed to `1`.
* *2.13*: The `dynamic_buffer` option was added.
* *2.13*: The `max_frame_size` option can now be set dynamically.