Lab 3, track 1: scaling experiment
The experiment starts a unique lab3-grade5-* Compose project, uses a free loopback LB port, removes the PostgreSQL host port, and deletes only that project's containers and volumes in finally. The normal project is not modified. API credentials and the experiment-specific database URL exist only in a temporary directory. Compose 2.24.4+, Go matching go.mod, Python 3.9+, Docker and the normal local .env/secrets/ bootstrap are required.
Run from the repository root:
python3 student-tests/lab3/grade5/run.py --plan student-tests/lab3/grade5/plan.controlled.json --output evidence/my-scaling-run
python3 student-tests/lab3/grade5/run.py --plan student-tests/lab3/grade5/plan.pool-screen.json --output evidence/my-pool-screen
python3 student-tests/lab3/grade5/run.py --plan student-tests/lab3/grade5/plan.confirm.json --output evidence/my-group-commit
python3 student-tests/lab3/grade5/run.py --plan student-tests/lab3/grade5/plan.db-cpu.json --output evidence/my-db-cpu
python3 student-tests/lab3/grade5/analyze.py evidence/my-scaling-run evidence/my-pool-screen evidence/my-group-commit --output evidence/my-analysis
python3 student-tests/lab3/grade5/verify_evidence.py evidence/my-db-cpu
Output directories must be empty. Plans contain all resource and workload parameters. plan.fixed.json is the initial exploratory method (cap 256 in its historical saved run); the current runner defaults to cap 1024, so consult each saved load.json for the actual cap rather than attributing old measurements to current code. plan.controlled.json fixes the total pool at 32 (32/16/8 connections per API for 1/2/4 replicas) and total API CPU/RAM at 4 vCPU/1024 MiB. Its growth series uses two replicas and 2/3/4 vCPU with 512/768/1024 MiB. PostgreSQL remains at 2 vCPU/512 MiB, LB at 1 vCPU/256 MiB, Redis at 0.5 vCPU/128 MiB.
Before each point, only the experiment's messages and message_idempotency are truncated, and 100,000 synthetic messages are inserted and analyzed. The pool screening and confirmation plans warm the server at the target rate for 10 s, reset to the same dataset, issue CHECKPOINT and wait 3 s. The measured Go process starts with a fresh HTTP transport; cold client connection establishment is part of this finite workload. The initial two series used only a 3 s / 200 RPS warmup and have stronger startup effects.
The Go client schedules independent POSTs at a fixed rate, uses unique keys, keeps HTTP connections, and does not retry. If the scheduler is over 250 ms late, or all in-flight slots are occupied, it counts the attempt as dropped. This bounded open-loop workload prevents unbounded memory use; its drops are client admission failures, not HTTP server responses. Requests have a 5 s network timeout. The primary completed throughput is successful_rps_wall, including the drain tail. successful_rps_window is also retained but must not be presented as steady completed throughput. success_latency_ms covers HTTP 201 only; the revised meter additionally records completed_full_latency_ms from planned departure to completion for all sent requests, including failed responses, and measures dispatch lag inside the goroutine. Drops have no completed latency and remain in the denominator of success ratio.
Record messages_added - successful_requests as unconfirmed committed writes. A timeout/503 does not imply a rolled-back operation. No mutation is retried under a different key. All experiments count this difference instead of silently equating HTTP acknowledgements with inserted rows.
Samples include CPU/RAM, PostgreSQL active/waiting connections, HAProxy queue/errors and individual collection timestamps. They are discrete observations, not continuous maxima. New confirmation runs also save before/after cgroup CPU throttling, PostgreSQL 18 pg_stat_io WAL timings, pg_stat_wal, effective durability settings and pg_stat_statements. In PostgreSQL 18 WAL timing moved to pg_stat_io; the old pg_stat_wal.wal_sync_time field does not exist. Snapshot boundaries include small instrumentation overhead.
plan.confirm.json changes only commit_delay between 0 and 1000 microseconds in ABBAAB order, with three points per setting. fsync=on and synchronous_commit=on must be verified in each diagnostic snapshot. This is a group commit latency/throughput tradeoff, not permission to weaken durability. Keep failed candidates and all raw results. A single laptop's Docker Desktop VM, thermal state, filesystem and competing host work limit generalization; the measured saturation belongs to this workload and resource envelope.
Optional charts use matplotlib. The original chart environment used matplotlib 3.11.2; install it in a separate virtual environment, then add --charts to analyze.py. Avoid installation, builds or unrelated benchmarks during measured intervals.
PG_POOL_DIAGNOSTICS=1 enables one-second aggregate pgxpool counters in the API logs. The experiment override sets it; the normal deployment does not. The first pool-causal run used an incorrect log filter (msg=pg_pool_stats instead of the actual default slog text format); its empty pool snapshots are missing evidence, not zero waiting. Subsequent runs accept both formats.
plan.wal-diagnostic.json is a causal diagnostic, not a deployable optimization: it compares synchronous_commit on/off/on on synthetic data in the disposable project, with fixed API/pool/resources. The off point weakens commit acknowledgement guarantees and cannot satisfy the lab's durability contract. It is used only to test whether waiting for WAL flush is limiting throughput. The final point restores on, effective settings are saved, public smoke follows the measured intervals, and the project is deleted. Never apply that diagnostic setting to the normal Compose project. The optional group-commit profile retains synchronous_commit=on and fsync=on.