Skip to main content

Load Testing

Reference configuration schema, benchmark targets, and metrics for the Framework M load-testing harness.


Configuration Schema

The harness reads a single YAML file passed to the CLI.

m benchmark --config config.yaml

Or, for a direct Python entry point:

python -m framework_m_studio.benchmarks.load_test --config config.yaml

Top-Level Keys

KeyTypeRequiredDescription
target_urlstringYesBase URL of the application under test.
authobjectYesDefault authentication provider for all scenarios.
usersobjectNoSpawn settings: peak, ramp_up_seconds, host.
duration_secondsintegerNoTotal benchmark duration. Default: 300.
seedobjectNoShared seed data (IDs, tenants, warehouses) referenced by scenarios.
targetslist[object]YesList of scenarios to execute.

Auth Providers

Session

auth:
mode: session
login_url: /api/auth/login
username: "${LOAD_TEST_USER}"
password: "${LOAD_TEST_PASSWORD}"

API Key

auth:
mode: api_key
header_name: X-API-Key
key: "${LOAD_TEST_API_KEY}"

Bearer

auth:
mode: bearer
token: "${LOAD_TEST_TOKEN}"

No Auth

auth:
mode: none

Custom

auth:
mode: custom
factory: myapp.benchmarks.auth.create_auth_header

Scenario Types

DocType Scenario

KeyTypeRequiredDescription
typestringYesdoctype
namestringYesDocType name.
mixobjectNoRatios for read, create, update, delete. Default: {read: 1.0}.
filtersobjectNoDefault query filters for list operations.
payload_overridesobjectNoStatic or templated field overrides.
weightintegerNoRelative weight among scenarios. Default: 1.
authobjectNoPer-scenario auth override.

Endpoint Scenario

KeyTypeRequiredDescription
typestringYesendpoint
namestringYesScenario identifier.
methodstringYesHTTP method.
pathstringYesRequest path. Supports templating.
headersobjectNoStatic or templated headers.
bodyobjectNoStatic or templated JSON body.
body_factorystringNoPython callable returning a body dict.
expect_statuslist[int]NoAllowed HTTP status codes. Default: [200].
weightintegerNoRelative weight. Default: 1.
authobjectNoPer-scenario auth override.

RPC Scenario

KeyTypeRequiredDescription
typestringYesrpc
namestringYesScenario identifier.
methodstringYesDotted RPC method name.
argslistNoPositional arguments.
kwargsobjectNoKeyword arguments.
expect_statuslist[int]NoAllowed HTTP status codes. Default: [200].
weightintegerNoRelative weight. Default: 1.
authobjectNoPer-scenario auth override.

Example Configuration

target_url: https://staging.myapp.example.com

auth:
mode: api_key
header_name: X-API-Key
key: "${LOAD_TEST_API_KEY}"

users:
peak: 100
ramp_up_seconds: 60
spawn_rate: 5

duration_seconds: 300

seed:
warehouse_id: "wh-001"
tenant_id: "tenant-001"

targets:
- type: doctype
name: Invoice
weight: 10
mix:
read: 0.7
create: 0.2
update: 0.1

- type: endpoint
name: bulk_import_invoices
method: POST
path: /api/invoices/bulk-import
weight: 2
headers:
X-Import-Mode: async
body:
source: csv
file_url: "{{ faker.url }}"
expect_status: [202, 200]

- type: rpc
name: reconcile_stock
method: framework.m.wms.reconcile_stock
weight: 1
kwargs:
warehouse_id: "{{ seed.warehouse_id }}"
item_codes:
- "{{ faker.uuid4 }}"

Reference Benchmark Targets

These targets are starting points for production-like staging environments. Adjust them to match your deployment size and SLA.

TargetValueNotes
Concurrent users1,000Simulated active users at peak.
Request rate10,000 requests / minuteAggregate across all scenarios.
p95 latency< 200 msFor standard CRUD and RPC operations.
Error rate< 1%Excluding expected 429 / 503 from rate limiting or readiness gates.
CPU utilization< 70% sustainedHeadroom for traffic spikes.
Memory growthStableNo visible leak over a 1-hour run.

Sustained Baseline Run

Before releasing to production, run a sustained 1-hour baseline and capture:

  1. Application container CPU and memory.
  2. Database CPU, connections, and slow query count.
  3. Cache hit rate (Redis or in-memory).
  4. Background job queue depth and worker throughput.
  5. Error rate and percentile latency over time.

Store the results in version control or a monitoring dashboard so regressions are easy to spot.


Metrics Glossary

MetricDescription
RPSRequests per second observed by Locust.
p5050th percentile response time.
p9595th percentile response time.
p9999th percentile response time.
Error rateFailed requests divided by total requests.
FailuresRequests whose HTTP status or assertion did not match expect_status.