Skip to content

Load Testing

Load testing validates that Momentum can handle expected (and peak) traffic without degraded performance or errors.

All scenarios live in momentum/load-tests/k6/scenarios/ and use k6’s ramping-vus executor, ramping from 0 VUs. Each test runs 7.5–10.5 minutes.

Scenario What it tests Peak VUs Duration
page-loads GET-only page renders 200 9m 30s
api Public API endpoint tests 200 10m 30s
livewire Livewire component snapshot extraction and update interactions 100 10m 30s
journeys Multi-step user flows: home → buildings → detail → scope → back 30 8m 30s
mixed Weighted mix: 40% page loads, 25% Livewire, 20% journeys, 15% API 200 10m

These push specific subsystems to find breaking points.

Scenario What it tests Peak VUs Duration
db-warmup High DB load: searches, sort+filter combos, pagination, page blasts — needs 10–20 app servers 30 7m 30s
db-crusher Insane DB load: JSONB filters, sorts, search combos — needs 20–40 app servers 500 10m
calcs-crusher Building show pages + scope switching — hammers momentum-calcs 100 9m
full-crusher Combined: DB + calcs + app + journeys + mutations 100 9m

For manual load testing, follow the instructions in the README.md file located at momentum/load-tests in the Momentum repository. It covers setup, configuration, and how to run and interpret test results.

In the Momentum repo, Claude has a built-in /load-test skill. Run:

/dev:load-test [env]

Where [env] is the target environment (e.g. staging, production, local). If you omit the environment, it defaults to testing your ephemeral environment. Use local to test against the locally running webapp.

k6 automatically opens a web dashboard when you run a test. If the dashboard stops showing data, do a hard refresh (Shift+Refresh) to reconnect to the metrics endpoint — it can be a bit flakey.

To monitor the Fly machines while a load test is running, use the fly-machines.py script in the Momentum repo:

Terminal window
# Ephemeral environment
./scripts/fly-machines.py --eph
# Named environment
./scripts/fly-machines.py --env {env}

For the app and calcs services, find them in the Fly.io dashboard (e.g. https://fly.io/apps/momentum-calcs-development) and click on Metrics to watch live charts during the test.

For MPG (if testing against an environment with Managed Postgres), navigate in the Fly.io UI to Managed Postgres > cluster name > Metrics to monitor database performance.

After a load test suite finishes, a per-tag report is automatically generated and opened in your browser. Individual steps in each load test are tagged — to see which endpoints they hit, grep the load test files in momentum/load-tests for tag names.