317 lines
19 KiB
Markdown
317 lines
19 KiB
Markdown
# Architecture B JMeter workloads
|
||
|
||
See [adaptation and verification](ARCHITECTURE-B.md) for provenance, compatibility and test limits.
|
||
|
||
|
||
JMeter 5.6.3 is installed on this development computer at `~/.local/bin/jmeter`.
|
||
Its launcher uses the installed Java 17; the default Java 26 cannot compile
|
||
JMeter's bundled Groovy scripts. The `jpgc-perfmon` 2.1 plugin is installed for live server monitoring.
|
||
|
||
Runs default to **30 minutes of warmup + 4 hours of measurement**. A few additional
|
||
seconds allow startup/draining. Only requests entirely inside the four-hour window
|
||
appear in `measured.csv`. Full raw samples remain in `samples.csv`. `run.json` and
|
||
`timeline.json` identify exact UTC measurement boundaries for your external meter.
|
||
|
||
## Scenarios
|
||
|
||
| Plan | User workflow |
|
||
|---|---|
|
||
| `recording` | View guidance/profile, save a home resting reading, retrieve it, view overview. |
|
||
| `review` | Profile, latest reading, filtered history, numerical insights, trends, overview. |
|
||
| `correction` | Record an erroneous/duplicate entry, correct it, check overview, delete that entry, confirm removal. |
|
||
| `mixed` | Expected session mix: 65% review, 30% recording, 5% correction. |
|
||
| `professional` | Assigned-patient list, profile/latest/history/insights/trends/overview; no writes. |
|
||
| `idle` | No measured API traffic; application and PostgreSQL remain running for the same observation period. |
|
||
|
||
Each thread retains its own account, patient and opaque token. Login occurs initially
|
||
and before token expiry, including during four-hour runs. Requests use the single Architecture B HTTPS application;
|
||
IDs come from actual responses. Nonexpected HTTP statuses and semantic failures stop
|
||
the affected user and invalidate the run. Only newly created correction-scenario
|
||
observations are deleted. Baseline and ordinary recording observations remain.
|
||
|
||
Per-user seeded random generators produce independent **Gaussian delays**:
|
||
interaction mean 1 second, standard deviation 250 ms, minimum 500 ms; between-session mean
|
||
120 seconds, standard deviation 30 seconds. Interaction delays use a Gaussian truncated symmetrically between 500 and 1500 ms,
|
||
retaining a 1-second expected mean. Between-session negative draws are clamped to zero. Threads also ramp up over
|
||
120 seconds. The seed is recorded; OS scheduling still affects exact timings.
|
||
These are configurable experimental assumptions, not measured population behaviour.
|
||
The default session frequency represents sustained, accelerated prototype activity;
|
||
for less frequent patient visits increase `--session-pause-ms` and its deviation.
|
||
A closed-loop user waits for each response; throughput decreases when the server slows.
|
||
Concurrency means resident simulated users, including their idle/thinking time.
|
||
|
||
## Live NUC monitoring in JMeter
|
||
|
||
All six plans contain **jp@gc – PerfMon Metrics Collector**, including idle.
|
||
The listener connects over TCP to the agent on the target (default port 4444),
|
||
samples every second, and writes `perfmon.csv` directly on this computer
|
||
through JMeter during the run. No server log transfer is needed. In GUI mode the
|
||
listener shows live graphs; use CLI mode for actual energy experiments.
|
||
|
||
Collected host metrics: CPU combined utilisation and I/O wait (%), memory usage
|
||
(% and actual-used bytes), swap-used bytes, disk read/write bytes per second,
|
||
and network received/sent bytes per second. These are system totals, not per-service
|
||
attribution. Network/disk counters depend on SIGAR's device support; zero values on
|
||
an idle host do not establish their accuracy. Compare the readings against Linux
|
||
utilities before treating the agent as a validated measurement instrument.
|
||
|
||
The runner checks agent access/metric availability before starting. It records
|
||
`--perfmon-host`, `--perfmon-port` and `--perfmon-interval-ms` (default 1000) in
|
||
`run.json`; by default the agent host matches `--host`. Failed, missing or widely
|
||
spaced measurements invalidate monitoring. `perfmon-measured.csv` excludes warmup,
|
||
decodes the plugin's synthetic `elapsed` field into metric values/units, and retains
|
||
timestamps from this computer's collector, not server-origin timestamps.
|
||
**PerfMon's elapsed field is not HTTP latency.** Host metrics stay separate
|
||
from application request counts. Raw `perfmon.csv` contains warmup and measured data.
|
||
`run.json` also includes each metric's sample count, mean and maximum.
|
||
|
||
Keep the agent running on the NUC for the full warmup and measured run. Its TCP
|
||
connection is plain-text and provides no authentication; restrict port 4444 to the
|
||
load-generator computer. Restart it with `--no-exec --udp-port 0 --tcp-port 4444`
|
||
to disable the agent's executable custom metrics; these plans use only built-in metrics.
|
||
`--no-perfmon` is for isolated workflow testing and explicitly records that no server
|
||
monitoring was collected. The plugin must still be installed to load its JMX element.
|
||
The validation fixture uses this switch and does not connect to the NUC.
|
||
|
||
[PerfMon listener documentation](https://jmeter-plugins.org/wiki/PerfMon/),
|
||
[agent metrics/protocol](https://github.com/undera/perfmon-agent).
|
||
|
||
## Live Shelly power in JMeter
|
||
|
||
Every scenario, including idle, contains one **Shelly live power** thread. It polls
|
||
`http://192.168.1.44/rpc/Switch.GetStatus?id=0` every second directly from
|
||
JMeter, independently of simulated users. There is no cloud dependency and no
|
||
post-run network transfer. No switch/set/reset commands are sent.
|
||
|
||
`shelly.csv` is written while JMeter runs, with timestamps, request status,
|
||
`shelly_power_watts`, `shelly_voltage_volts`, `shelly_current_amps` and cumulative
|
||
`shelly_energy_wh`. Raw readings include warmup. `shelly-measured.csv` brackets only
|
||
the measured interval, interpolating its boundaries; `run.json` includes mean watts,
|
||
integrated joules/kWh and the counter's Wh delta converted to joules/kWh.
|
||
The timestamp is approximated by each polling request's midpoint on this computer.
|
||
Meter requests are excluded from the application's request-rate and latency summary.
|
||
JMeter's overall console summary includes meter polls; use `run.json` and
|
||
`measured.csv` for the application-only figures.
|
||
|
||
Energy from sampled power is the sum of the recorded in-window power values, each multiplied by the nominal polling interval. This assumes each reading represents that interval; actual polling timestamps may differ and sample coverage is reported. Counter deltas provide a separate cross-check;
|
||
the device's counter update granularity can make short runs report little or no
|
||
counter change despite nonzero power. Both boundary interpolation and meter accuracy
|
||
limit precision; this does not claim calibration. The plug measures what is connected
|
||
to its outlet, including the NUC's power-adapter losses. Connect only the intended
|
||
measured equipment. Its internal temperature is **not the NUC CPU temperature**.
|
||
|
||
The runner defaults to this plug and checks its status before starting. Override with
|
||
`--shelly-host`, `--shelly-port`, `--shelly-switch-id` or `--shelly-interval-ms`.
|
||
There is a short unmeasured drain after the four-hour window to obtain its closing
|
||
boundary. Missing samples, long gaps, failed polls and counter resets invalidate the
|
||
power measurement; they are not treated as zero watts. `--no-shelly` is for isolated
|
||
workflow testing, and records that power monitoring was disabled. The current plug
|
||
has authentication disabled; authenticated device access is not yet implemented.
|
||
|
||
The runner configures JMeter's `sample_variables` so the numeric columns are saved.
|
||
For a manual GUI/CLI launch, pass:
|
||
|
||
```bash
|
||
-Jsample_variables=shelly_power_watts,shelly_voltage_volts,shelly_current_amps,shelly_energy_wh
|
||
```
|
||
|
||
Use the runner for experiment timing, summaries and completeness checks. A new
|
||
power-monitoring-only check can be run without application requests:
|
||
|
||
```bash
|
||
python3 tools/energy-jmeter/verify-shelly.py --host 192.168.1.44 --output tools/energy-jmeter/results/shelly-check-new
|
||
```
|
||
|
||
[Shelly switch status and energy units](https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/Switch/).
|
||
|
||
## 1. Prepare Architecture B accounts (outside measurement)
|
||
|
||
Use a disposable B installation and synthetic data. The generator reads a **copy** of
|
||
B's JSON configuration, retains all existing settings/accounts/assignments, and
|
||
adds patient password hashes. It does not change the installed file. No registration
|
||
API or application code change is needed.
|
||
|
||
Build the portable hash helper from this repository (do not copy old binaries):
|
||
|
||
```bash
|
||
dotnet publish tools/PasswordHash -c Release --self-contained false -p:UseAppHost=false -o tools/energy-jmeter/hash-tool
|
||
```
|
||
|
||
Copy this tooling and hash-tool output to the B test host, then generate a new fixture:
|
||
|
||
```bash
|
||
sudo python3 tools/energy-jmeter/create-accounts.py --configuration /etc/healthapp-b/appsettings.json --output /var/lib/healthapp-b-energy-fixture --count 100
|
||
```
|
||
|
||
Review `/var/lib/healthapp-b-energy-fixture/appsettings.json` privately. Back up the
|
||
installed configuration, then install this copy **root:healthapp-b, mode 640** at
|
||
`/etc/healthapp-b/appsettings.json` and restart `healthapp-b.service`. Preserve the
|
||
original accounts and predefined assignments. This is an explicit test-host setup
|
||
operation; the generator never installs configuration or restarts services.
|
||
|
||
Transfer only generated `accounts.json` privately to the load generator, and export
|
||
`/etc/healthapp-b/healthapp-ca.crt` as its application trust root. Do not transfer the
|
||
installed appsettings.json (it contains database/private-key configuration).
|
||
|
||
```bash
|
||
mkdir -p tools/energy-jmeter/.private
|
||
chmod 700 tools/energy-jmeter/.private
|
||
# Place accounts.json (mode 600) and healthapp-ca.crt in this private directory.
|
||
python3 tools/energy-jmeter/prepare.py --base-url https://B_HOST:5443 --ca tools/energy-jmeter/.private/healthapp-ca.crt --accounts tools/energy-jmeter/.private/accounts.json --output tools/energy-jmeter/.private/dataset --days 30
|
||
```
|
||
|
||
Preparation uses the preserved public API and verified HTTPS, creates/reuses profiles,
|
||
and seeds 60 readings per patient with the original distribution of contexts. It
|
||
excludes installation-check. It does not reset workload-created records. Use equivalent
|
||
fresh/restored synthetic datasets for A/B comparison; do not access live A databases.
|
||
A new output folder is required when preparing again.
|
||
|
||
For read-only shared-account runs supply a CSV with account_id,password,patient_id
|
||
and explicitly use `--allow-shared-read-account`. Professional runs need a separate
|
||
CSV of configured professional credentials and assigned patient IDs. B's generated
|
||
professional has no assignments; configure Access:ProfessionalAssignments outside
|
||
measurement and restart the application. Preflight rejects missing role/assignments.
|
||
See [B installation](../../deploy/INSTALLATION.md) for configuration ownership and trust.
|
||
|
||
## 2. Find a suitable concurrency before the four-hour run
|
||
|
||
For the 8 GB, 8th/9th-generation Intel NUC, try 10, 25, 50 and 100 users in short
|
||
capacity runs. Generate more accounts before trying 200. Age/RAM do not establish
|
||
capacity. Review CPU, RAM, thermal throttling, error rate and latency on the NUC.
|
||
Choose your acceptable latency before deciding which level to measure for four hours.
|
||
For example, this trial lasts 2 minutes of warmup plus 5 measured minutes:
|
||
|
||
```bash
|
||
python3 tools/energy-jmeter/run.py mixed --host 192.168.1.125 --ca tools/energy-jmeter/.private/healthapp-ca.crt --users-file tools/energy-jmeter/.private/dataset/users.csv --users 50 --warmup 120 --duration 300 --output tools/energy-jmeter/results/capacity-50
|
||
```
|
||
|
||
A short check identifies obvious overload; it does not establish thermal stability
|
||
or long-run capacity. Output directories must be new. Failed users are not silently
|
||
replaced. Do not use a partial/failed run as a successful four-hour measurement.
|
||
|
||
## 3. Run a full experiment
|
||
|
||
Ensure the NUC is powered through the Shelly plug at **192.168.1.44**, then run:
|
||
|
||
```bash
|
||
python3 tools/energy-jmeter/run.py mixed --host 192.168.1.125 --ca tools/energy-jmeter/.private/healthapp-ca.crt --users-file tools/energy-jmeter/.private/dataset/users.csv --users 100 --warmup 1800 --duration 14400 --output tools/energy-jmeter/results/mixed-100-run1
|
||
```
|
||
|
||
Substitute another scenario or concurrency as needed. `--warmup 600` or `1200`
|
||
selects 10/20 minutes; the four measured hours remain unchanged. Choose a warmup
|
||
that reaches stable server temperature/power rather than assuming a universal value.
|
||
`--seed 42`, `--think-min-ms`, `--think-mean-ms`, `--think-stddev-ms`, `--session-pause-ms` and
|
||
`--session-stddev-ms` control timing. Include these identically across comparisons.
|
||
|
||
Use the same-duration `idle` run to establish baseline power:
|
||
|
||
```bash
|
||
bash tools/energy-jmeter/run-idle.sh
|
||
```
|
||
|
||
The idle runner sends zero application requests, including during startup. No CA, credentials or dataset is needed. JMeter collects only PerfMon host metrics and Shelly power readings.
|
||
The application/PostgreSQL stay running as they are. The runner does not start, stop or restart them. Keep the PerfMon agent running. The one-command launcher creates a timestamped result folder under `results/idle-*`. The load generator and HTML-report
|
||
creation stay on this computer, outside the NUC's energy measurement. Keep server
|
||
power settings, dataset, service versions, logging and other workloads consistent.
|
||
Record those settings, thermal state, meter sampling interval and clock synchronisation.
|
||
Repeat runs and vary their order to check drift. The inherited live-monitoring observations refer to Architecture A. B verification and its limits are recorded separately in ARCHITECTURE-B.md.
|
||
|
||
## 4. Read results and energy
|
||
|
||
`run.json` contains measurement boundaries, request/error counts, request rate,
|
||
p95 latency, random seed, timings and plan hash. JMeter CSV excludes response bodies,
|
||
request headers and passwords. The private runtime credential CSV is deleted at exit;
|
||
keep the whole result directory private and inspect logs before sharing.
|
||
|
||
JMeter now collects the Shelly readings live and the runner calculates measured-window energy automatically. For another external meter, export its readings as
|
||
CSV with `timestamp,power_watts` (timezone-qualified ISO timestamps, increasing,
|
||
covering the full interval), then integrate only the measured four hours:
|
||
|
||
```bash
|
||
python3 tools/energy-jmeter/energy.py tools/energy-jmeter/results/mixed-100-run1/run.json power.csv
|
||
```
|
||
|
||
The tool interpolates interval edges and integrates watts using trapezoids. It reports
|
||
joules, kWh, mean watts and joules per HTTP request. `--idle-watts VALUE` additionally
|
||
reports energy above the measured idle mean. A request is not a user session;
|
||
compare scenario/mix and achieved throughput when interpreting efficiency.
|
||
Raw meter data must be preserved; missing intervals cannot be repaired by JMeter. The same rule applies to Shelly polls.
|
||
|
||
JMeter's stock HTTPS client trusts test certificates. The Python runner verifies the
|
||
provided CA and hostname during preflight; JMeter traffic itself remains encrypted
|
||
but does not provide certificate validation. Do not describe this as a TLS security test.
|
||
|
||
## Verification
|
||
|
||
```bash
|
||
python3 tools/energy-jmeter/generate-plans.py
|
||
python3 tools/energy-jmeter/verify-plans.py
|
||
python3 tools/energy-jmeter/verify-perfmon.py
|
||
python3 tools/energy-jmeter/verify-shelly.py
|
||
python3 tools/energy-jmeter/verify-idle.py
|
||
```
|
||
|
||
The validation script exercises every plan against an isolated local HTTPS contract
|
||
stub, including dynamic IDs, token renewal, status/semantic assertions, deletion and
|
||
warmup exclusion. It does not prove capacity or replace the application's acceptance
|
||
suite. The real-server short capacity trial is required before a four-hour measurement.
|
||
|
||
References: [Apache release](https://jmeter.apache.org/download_jmeter.cgi),
|
||
[CLI load testing](https://jmeter.apache.org/usermanual/get-started.html),
|
||
[JMeter components](https://jmeter.apache.org/usermanual/component_reference.html).
|
||
|
||
For a short live monitoring-only check (no patient requests):
|
||
|
||
```bash
|
||
python3 tools/energy-jmeter/verify-perfmon.py --host 192.168.1.125 --output tools/energy-jmeter/results/perfmon-check-new
|
||
```
|
||
|
||
This verifies that JMeter saves readings while it is still running, then checks
|
||
metric coverage and decoding. An inherited Architecture A monitoring-only check succeeded against the NUC;
|
||
comparison with independent Linux readings is still needed to validate accuracy.
|
||
|
||
## Time-aligned graphs and one-second request reporting
|
||
|
||
Every finished run generates `report.html` (interactive), `report.png`, `report.svg`
|
||
and `per-second.csv`. The plotting dependency is Matplotlib, already installed on
|
||
this computer. If setting up another load generator, install Matplotlib there.
|
||
All panels share UTC timestamps and experiment-relative one-second intervals,
|
||
starting at the recorded warmup start. Warmup is shaded; measurement begins after
|
||
the exact configured warmup duration.
|
||
|
||
CPU, RAM, power, disk and network values are averaged only when multiple samples
|
||
fall into a second; missing readings stay blank and create graph gaps. Application
|
||
requests and failed requests are counted individually per second. Mean/p95/max
|
||
latency is grouped by request start time, with p95 using the nearest-rank definition.
|
||
Requests spanning the measurement end are excluded from measured application figures,
|
||
matching `run.json`. Meter requests and internal timing samples never count as
|
||
application traffic. Seconds without requests have zero request/error counts and
|
||
no response-time value. The graph keeps every one-second bin; a wide full-run view
|
||
can visually compress points. Use the interactive range controls to inspect seconds.
|
||
|
||
For a running experiment, generate a snapshot or keep refreshing its artifacts:
|
||
|
||
```bash
|
||
python3 tools/energy-jmeter/report.py tools/energy-jmeter/results/RUN_FOLDER
|
||
python3 tools/energy-jmeter/report.py tools/energy-jmeter/results/RUN_FOLDER --follow
|
||
```
|
||
|
||
`--follow` refreshes artifacts every minute, using one-second data, and generates the
|
||
final report when the run finishes. Open `report.html` locally and use **Refresh
|
||
snapshot** to load new data. It provides a shared cursor across panels and a measured-
|
||
window selection. The latest seconds of a running snapshot are provisional because
|
||
JMeter writes request samples after their responses arrive. Missing future seconds
|
||
are not plotted as zeros. Report creation runs on the load generator.
|
||
|
||
Verify aggregation with `python3 tools/energy-jmeter/verify-report.py`.
|
||
|
||
For intentionally heavy shared-data capacity trials, use `review`,
|
||
`--allow-shared-read-account`, `--capacity-trial` and the desired thread count.
|
||
`--capacity-trial` restarts a read-only session after failures to maintain the trial
|
||
duration. Errors are still recorded and the run is marked unsuccessful if any occur;
|
||
the graphs remain useful for finding capacity. This mode permits no write scenarios.
|
||
First-use certificate pinning, when used instead of the installation CA, trusts the
|
||
certificate presented on that first connection; it is not an independently verified CA.
|
||
|
||
The inherited Architecture A 26-thread selection and its historical evidence are preserved in [WORKLOAD-SELECTION.md](WORKLOAD-SELECTION.md). This is not a B capacity result. For paired comparisons keep concurrency/pacing/workload identical and record B admission settings; do not tune away 503 responses or exclude failures.
|