Skip to content

Commit

Permalink
Lower the lower dynamic buffer value to 1024
Browse files Browse the repository at this point in the history
There's not a big performance difference between 8192 and 1024
so let's use less memory at the start of the connection.
  • Loading branch information
essen committed Feb 5, 2025
1 parent 073c481 commit 9d49122
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion doc/src/manual/cowboy_http.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ connection_type (supervisor)::

Whether the connection process also acts as a supervisor.

dynamic_buffer ({8192, 131072})::
dynamic_buffer ({1024, 131072})::

Cowboy will dynamically change the socket's `buffer` size
depending on the size of the data it receives from the socket.
Expand Down
2 changes: 1 addition & 1 deletion doc/src/manual/cowboy_http2.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ The connection window will only get updated when its size
becomes lower than this threshold, in bytes. This is to
avoid sending too many `WINDOW_UPDATE` frames.

dynamic_buffer ({8192, 131072})::
dynamic_buffer ({1024, 131072})::

Cowboy will dynamically change the socket's `buffer` size
depending on the size of the data it receives from the socket.
Expand Down
2 changes: 1 addition & 1 deletion doc/src/manual/cowboy_websocket.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ options and the zlib compression options. The
defaults optimize the compression at the expense
of some memory and CPU.

dynamic_buffer ({8192, 131072})::
dynamic_buffer ({1024, 131072})::

Cowboy will dynamically change the socket's `buffer` size
depending on the size of the data it receives from the socket.
Expand Down
2 changes: 1 addition & 1 deletion src/cowboy.erl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ ensure_dynamic_buffer(TransOpts, #{dynamic_buffer := DynamicBuffer}) ->
ensure_dynamic_buffer(TransOpts=#{socket_opts := SocketOpts}, _) ->
case proplists:get_value(buffer, SocketOpts, undefined) of
undefined ->
{TransOpts#{socket_opts => [{buffer, 8192}|SocketOpts]}, {8192, 131072}};
{TransOpts#{socket_opts => [{buffer, 1024}|SocketOpts]}, {1024, 131072}};
_ ->
{TransOpts, false}
end.
Expand Down

0 comments on commit 9d49122

Please sign in to comment.