From eacfdb2451bebb50ad7535ab7a6ccfbaac4cc9de Mon Sep 17 00:00:00 2001 From: SimpleTest Date: Mon, 20 Jul 2026 04:36:20 +0300 Subject: [PATCH] test: measure database load and pool pressure --- README.md | 16 + compose.load.yaml | 11 + docs/performance.md | 78 ++++ lib/who_need_help/help.ex | 2 +- lib/who_need_help_web/telemetry.ex | 25 ++ scripts/load-run.sh | 390 ++++++++++++++++++ scripts/quality.sh | 5 + scripts/rotate-load-metrics-token.sh | 38 ++ test/who_need_help/mutual_aid_flow_test.exs | 15 + .../controllers/metrics_controller_test.exs | 4 + 10 files changed, 583 insertions(+), 1 deletion(-) create mode 100755 scripts/rotate-load-metrics-token.sh diff --git a/README.md b/README.md index 895101d..adf9223 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,22 @@ The same external-service protocol drill used by CI can be run independently: ./scripts/external-boundaries-run.sh local-boundaries ``` +Run the isolated HTTP/WebSocket/authenticated chat/tracking load profile with +resource, PostgreSQL statement, database-connection, and Ecto pool-wait +measurements: + +```bash +./scripts/load-stack-up.sh +./scripts/load-run.sh local-load +./scripts/load-stack-stop.sh +``` + +The profile has its own generated mode-`0600` environment, Compose project, +and PostgreSQL volume. It does not use or mutate the ordinary public Compose +database. Exact inputs and threshold-free evidence are retained below +`output/performance/local-load/`; see +[Performance measurement](docs/performance.md) for scope and interpretation. + The cursor-pagination database benchmark also creates a one-run Compose project, random database credentials, and a separate PostgreSQL volume: diff --git a/compose.load.yaml b/compose.load.yaml index 2fb4515..62400e8 100644 --- a/compose.load.yaml +++ b/compose.load.yaml @@ -1,4 +1,15 @@ services: + db: + # Query-level statistics are enabled only for the isolated load profile. + # PostgreSQL requires pg_stat_statements in shared_preload_libraries and a + # server restart; the ordinary Compose database is not changed. + command: + - postgres + - -c + - shared_preload_libraries=pg_stat_statements + - -c + - compute_query_id=on + proxy: networks: edge: diff --git a/docs/performance.md b/docs/performance.md index 7a71424..2562606 100644 --- a/docs/performance.md +++ b/docs/performance.md @@ -97,11 +97,24 @@ Each run writes ignored evidence below `output/performance/