Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion frameworks/roadrunner/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"json-comp",
"json-tls",
"8gbit",
"async",
"async-db",
"static-tls",
"fortunes",
Expand All @@ -30,7 +31,8 @@
"baseline-h3",
"static-h3",
"echo-ws",
"echo-ws-pipeline"
"echo-ws-pipeline",
"echo-ws-limited"
],
"maintainers": ["williamthome"]
}
4 changes: 4 additions & 0 deletions frameworks/roadrunner/src/roadrunner_httparena_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ start(_StartType, _StartArgs) ->
%% connection-churn profiles.
max_clients => 65536,
num_acceptors => 100,
%% The async profile opens 32K connections at once; deepen the
%% kernel accept queue past the storm size (the kernel clamps
%% this to `net.core.somaxconn`), like the h2c listener below.
socket_backlog => 32768,
%% WebSocket sessions inherit the listener's 64 KB socket buffer,
%% held live per socket; the echo profiles exchange small text
%% frames, so shrink it per roadrunner's ws.recv_buffer production
Expand Down
12 changes: 12 additions & 0 deletions frameworks/roadrunner/src/roadrunner_httparena_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ routes() ->
{~"/baseline11", ?MODULE, undefined},
{~"/baseline2", ?MODULE, undefined},
{~"/pipeline", ?MODULE, undefined},
{~"/delay/:ms", ?MODULE, undefined},
#{path => ~"/json/:count", handler => ?MODULE, middlewares => [roadrunner_compress]},
{~"/echo", ?MODULE, undefined},
{~"/async-db", ?MODULE, undefined},
Expand Down Expand Up @@ -42,6 +43,8 @@ handle_route(~"/baseline2", Req) ->
baseline(Req);
handle_route(~"/pipeline", Req) ->
{roadrunner_resp:text(200, ~"ok"), Req};
handle_route(<<"/delay/", _/binary>>, Req) ->
delay_endpoint(Req);
handle_route(<<"/json/", _/binary>>, Req) ->
json_endpoint(Req);
handle_route(~"/echo", Req) ->
Expand Down Expand Up @@ -159,6 +162,15 @@ baseline(Req) ->
end,
{roadrunner_resp:text(200, integer_to_binary(A + B + BodyN)), Req2}.

%% Async-delay endpoint: read the per-request delay from the path, wait
%% idiomatically (each pending request is its own lightweight process,
%% so the wait suspends only this connection), and answer the parsed
%% number as the body.
delay_endpoint(Req) ->
#{~"ms" := MsBin} = roadrunner_req:bindings(Req),
ok = timer:sleep(binary_to_integer(MsBin)),
{roadrunner_resp:text(200, MsBin), Req}.

json_endpoint(Req) ->
Count = binding_int(~"count", Req, 0),
M = qs_int(~"m", Req, 1),
Expand Down
Loading