Skip to content
Merged
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
2 changes: 1 addition & 1 deletion frameworks/roadrunner/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM erlang:29.0-alpine AS build
RUN apk add --no-cache ca-certificates git
WORKDIR /src
COPY rebar.config ./
COPY rebar.config rebar.lock ./
COPY config ./config
COPY src ./src
RUN rebar3 as prod release
Expand Down
18 changes: 8 additions & 10 deletions frameworks/roadrunner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@

## Profiles

Covered (21 of 28 profiles):

- `baseline`, `pipelined`, `limited-conn`
- `json`, `json-comp`, `json-tls`
- `upload`
- `async-db`
- `static`, `static-h2`
- `fortunes`, `crud`
- `baseline-h2`, `baseline-h2c`, `json-h2c`
Covered:

- `baseline`, `pipelined`, `limited-conn`, `async`
- `latency-1m`, `latency-10k`, `latency-500k-8cpu`
- `json-comp`, `json-tls`, `8gbit`, `static-tls`
- `async-db`, `fortunes`
- `baseline-h2`, `static-h2`, `baseline-h2c`, `json-h2c`
- `baseline-h3`, `static-h3`
- `echo-ws`, `echo-ws-pipeline`
- `echo-ws`, `echo-ws-pipeline`, `echo-ws-limited`

Deferred (tracked under [HttpArena coverage gaps](https://github.com/arizona-framework/roadrunner/blob/main/docs/roadmap.md) in the roadrunner roadmap):

Expand Down
9 changes: 6 additions & 3 deletions frameworks/roadrunner/rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
{minimum_otp_vsn, "29"}.

{deps, [
{roadrunner, "0.9.2"},
{roadrunner, "0.10.2"},
{epgsql, "4.8.0"},
{ecpool, "0.4.2"}
{ecpool, "0.4.2"},
% Arizona's template engine renders /fortunes.
{arizona, "0.2.0"}
]}.

{relx, [
{release, {roadrunner_httparena, "0.1.0"},
[roadrunner_httparena, ecpool, roadrunner]},
%% Arizona is only a template library here: loaded, never started.
[roadrunner_httparena, ecpool, roadrunner, {arizona, load}]},
{sys_config, "./config/sys.config"},
{dev_mode, false},
{include_erts, true},
Expand Down
14 changes: 10 additions & 4 deletions frameworks/roadrunner/rebar.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
{"1.2.0",
[{<<"ecpool">>,{pkg,<<"ecpool">>,<<"0.4.2">>},0},
[{<<"arizona">>,{pkg,<<"arizona">>,<<"0.2.0">>},0},
{<<"ecpool">>,{pkg,<<"ecpool">>,<<"0.4.2">>},0},
{<<"epgsql">>,{pkg,<<"epgsql">>,<<"4.8.0">>},0},
{<<"fs">>,{pkg,<<"fs">>,<<"11.4.1">>},1},
{<<"gproc">>,{pkg,<<"gproc">>,<<"0.8.0">>},1},
{<<"roadrunner">>,{pkg,<<"roadrunner">>,<<"0.9.2">>},0},
{<<"roadrunner">>,{pkg,<<"roadrunner">>,<<"0.10.2">>},0},
{<<"telemetry">>,{pkg,<<"telemetry">>,<<"1.4.2">>},1}]}.
[
{pkg_hash,[
{<<"arizona">>, <<"9FC13AC4387F293EE118C0B384016693F945A1E43121CBEB91845E4567C29802">>},
{<<"ecpool">>, <<"2F466096B81B9C945494CDF6A554ACAD4C31B0AC5A3D2B1929B822BA7C9B9F6E">>},
{<<"epgsql">>, <<"C491B141B8C37BCE7B67F2079F168F339BB374A7CF9A286CB3B40AD1CD3FABE5">>},
{<<"fs">>, <<"11FB3153BB2E1DE851B8263BB5698D526894853C73A525EBEB5E69108B2D25CD">>},
{<<"gproc">>, <<"CEA02C578589C61E5341FCE149EA36CCEF236CC2ECAC8691FBA408E7EA77EC2F">>},
{<<"roadrunner">>, <<"32F018774658018B84AD5BE9C920A67DFF834E5425042B891921F952531AA2A8">>},
{<<"roadrunner">>, <<"9203479DB306FD881A52246BA24BFE515C5C3B89DB1A62DF3CDD3452176FD51E">>},
{<<"telemetry">>, <<"A0CB522801DFFB1C49FE6E30561BADFFC7B6D0E180DB1300DF759FAA22062855">>}]},
{pkg_hash_ext,[
{<<"arizona">>, <<"239FFCED3FB0443F25BDF40EA4D0DA94B1DBA1C4D785CC3EC03ECDFC41852D77">>},
{<<"ecpool">>, <<"4E834C138ABF742F281ECEBEF69D37C6D7BF0A4E8E23965CF3826E027B723ED2">>},
{<<"epgsql">>, <<"00E550006A62FB439FC7E879419443C889C34605E9B9DC406029D8BAA1AD79D8">>},
{<<"fs">>, <<"DD00A61D89EAC01D16D3FC51D5B0EB5F0722EF8E3C1A3A547CD086957F3260A9">>},
{<<"gproc">>, <<"580ADAFA56463B75263EF5A5DF4C86AF321F68694E7786CB057FD805D1E2A7DE">>},
{<<"roadrunner">>, <<"A79186E24FE9EFAE0379F58A69FFEA4459A91B5B672C49FF6CC11E5C07680A0A">>},
{<<"roadrunner">>, <<"19B1B3DC0F6FF3CCFFBBB0F80E780A49D7BDC0D82EEE66610EA777DE319D1C19">>},
{<<"telemetry">>, <<"928F6495066506077862C0D1646609EED891A4326BEE3126BA54B60AF61FEBB1">>}]}
].
23 changes: 4 additions & 19 deletions frameworks/roadrunner/src/roadrunner_httparena_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ start(_StartType, _StartArgs) ->
{ok, SupPid} = roadrunner_httparena_sup:start_link(),
ok = roadrunner_httparena_dataset:load(),
_ = roadrunner_httparena_db:start_pool(),
ok = roadrunner_httparena_crud:init(),
Routes = roadrunner_httparena_handler:routes(),
HttpPort = application:get_env(roadrunner_httparena, http_port, 8080),
{ok, _} = roadrunner:start_listener(httparena_http, #{
Expand All @@ -29,21 +28,12 @@ start(_StartType, _StartArgs) ->
%% held live per socket; the echo profiles exchange small text
%% frames, so shrink it per roadrunner's ws.recv_buffer production
%% guidance for small-message, high-concurrency deployments.
ws => #{recv_buffer => 4096},
%% 25 MB headroom for the 8gbit profile (validator goes up to 20 MB).
max_content_length => 26214400,
%% Manual body buffering: handlers read the body themselves via
%% `roadrunner_req:read_body[_chunked]/1`. Lets the echo handler
%% stream chunks instead of buffering the entire 20 MB body in
%% the conn process before dispatch. Auto-mode handlers
%% (`baseline11` POST) still work transparently via `read_body/1`.
body_buffering => manual
ws => #{recv_buffer => 4096}
}),
H2cPort = application:get_env(roadrunner_httparena, h2c_port, 8082),
{ok, _} = roadrunner:start_listener(httparena_h2c, #{
port => H2cPort,
routes => Routes,
max_content_length => 26214400,
%% h2 multiplexes many streams per connection: the connection cap
%% covers the largest h2c profile (4096 connections) with headroom,
%% and the advertised `max_concurrent_streams` bounds per-stream
Expand All @@ -68,8 +58,7 @@ start(_StartType, _StartArgs) ->
%% h2c prior-knowledge: `[http2]` on a plain-TCP listener
%% serves h2 directly (client sends the h2 preface, no
%% `Upgrade: h2c` negotiation).
protocols => [{http2, #{max_concurrent_streams => 4}}],
body_buffering => manual
protocols => [{http2, #{max_concurrent_streams => 4}}]
}),
case tls_opts() of
{ok, TlsOpts} ->
Expand All @@ -79,15 +68,12 @@ start(_StartType, _StartArgs) ->
routes => Routes,
max_clients => 65536,
num_acceptors => 100,
max_content_length => 26214400,
tls => TlsOpts,
body_buffering => manual
tls => TlsOpts
}),
H2Port = application:get_env(roadrunner_httparena, h2_port, 8443),
{ok, _} = roadrunner:start_listener(httparena_h2, #{
port => H2Port,
routes => Routes,
max_content_length => 26214400,
tls => TlsOpts,
%% Same connection/stream bounds as the h2c listener above.
max_clients => 8192,
Expand All @@ -96,8 +82,7 @@ start(_StartType, _StartArgs) ->
%% `http3` co-serves over QUIC on UDP 8443 (same port
%% number) and auto-advertises `Alt-Svc: h3=":8443"` on
%% the h1/h2 responses. Serves baseline-h3 / static-h3.
protocols => [{http2, #{max_concurrent_streams => 16}}, http1, http3],
body_buffering => manual
protocols => [{http2, #{max_concurrent_streams => 16}}, http1, http3]
});
skip ->
ok
Expand Down
121 changes: 0 additions & 121 deletions frameworks/roadrunner/src/roadrunner_httparena_crud.erl

This file was deleted.

30 changes: 0 additions & 30 deletions frameworks/roadrunner/src/roadrunner_httparena_db.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,6 @@
%% `#statement{}` record instead of re-parsing on every request.
statements() ->
#{
read => ~"""
SELECT id, name, category, price, quantity, active, tags,
rating_score, rating_count
FROM items
WHERE id = $1
""",
list => ~"""
SELECT id, name, category, price, quantity, active, tags,
rating_score, rating_count
FROM items
WHERE category = $1
ORDER BY id
LIMIT $2 OFFSET $3
""",
count => ~"SELECT COUNT(*) FROM items WHERE category = $1",
create => ~"""
INSERT INTO items (id, name, category, price, quantity,
active, tags, rating_score, rating_count)
VALUES ($1, $2, $3, $4, $5, true, '[]'::jsonb, 0, 0)
ON CONFLICT (id) DO UPDATE
SET name = EXCLUDED.name,
category = EXCLUDED.category,
price = EXCLUDED.price,
quantity = EXCLUDED.quantity
""",
update => ~"""
UPDATE items
SET name = $2, category = $3, price = $4, quantity = $5
WHERE id = $1
""",
async_db => ~"""
SELECT id, name, category, price, quantity, active, tags,
rating_score, rating_count
Expand Down
31 changes: 31 additions & 0 deletions frameworks/roadrunner/src/roadrunner_httparena_fortunes.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-module(roadrunner_httparena_fortunes).
-moduledoc """
The /fortunes page as an Arizona template: the static markup is the
template's, and every fortune is interpolated and HTML-escaped by the
engine. The page root carries `az_nodiff`, which its row template
inherits: it is rendered once per request with no live client to patch,
so it needs none of the markers Arizona keeps for updating a live page.
""".

-include_lib("arizona/include/arizona_stateless.hrl").

-export([render/1]).

-spec render(arizona_template:bindings()) -> arizona_template:template().
render(Bindings) ->
?html([
~"<!doctype html>",
{html, [az_nodiff], [
{head, [], {title, [], ~"Fortunes"}},
{body, [],
{table, [], [
{tr, [], [{th, [], ~"id"}, {th, [], ~"message"}]},
?each(
fun({Id, Message}) ->
{tr, [], [{td, [], Id}, {td, [], Message}]}
end,
?get(fortunes)
)
]}}
]}
]).
Loading