The samples.csv row of an interval that touches the start of a freeze
now gets the window of its unfrozen part, as the window aggregates do
since the thaw correction. CPU per successful request is no longer
computed for a container absent from the window. The definitions in
the summary describe which intervals the window maximum covers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A sample interval that crosses docker pause or unpause carried the CPU
spent before the pause and the burst after unpause into the failover
window by proportional split. Use the pause and unpause moments from
Docker events so that interval CPU lands outside the frozen span.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run bench/sampler.sh in a new scan mode (cgroup walk, no network, no
psql or LB polling) for the whole load of the failover and rollout
profiles. bench/resources.py turns the samples into per-window CPU,
throttling and memory of every component and the VM, with
samples.csv, resources.csv and summary sections; CPU per successful
request only in steady windows. Check the peak CPU budget before the
stand starts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Configs may carry a fifth element, the PostgreSQL CPU limit, which goes
into the config key (-pg<CPU>), the budget and the cell stand. Series db:
1, 2, 4 replicas at the tight limit and a 4 x 1 control at 2 CPU; label
summaries show PostgreSQL CPU at R* against its limit and throttling.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
plots.py summary gains per-request CPU by component, PostgreSQL waits and
pool, H1b throttling and memory peaks; compare.py and plots.py headers
name the spec, change and host; errors logs match 5xx by status field and
keep the exception tail; series labels record sampler limits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Series a/b/pool/ab/quick in bench/run.py: per-cell fresh stand with the
configuration's replicas and max_connections, open-model mixed profile
(k6/mixed.js), fixed levels and R* search by SLO, a sampler container
for cgroup, VM, HAProxy and PostgreSQL metrics, resume and a stand
lock. Pure helpers in bench/scaling.py, SVG plots in bench/plots.py,
series mode for bench_compare and bench_ab. Hypotheses H1-H3 go to
REPORT.md before the first series.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A one-off run --rm left the migrate container of the previous image in
the stand; scripts/restart.sh then started it as a dependency of api and
the old migrations failed on the newer schema, so test-persistence broke.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scripts/rolling-update.sh (make rolling_update) replaces API replicas one
by one: build, migrations once, new replica UP in HAProxy, old replica
drained and put into maintenance through the LB runtime API on loopback,
then stopped and removed; the slot is reset once DNS drops the address.
Expand migration adds messages.instance_id with a lock timeout. The bench
rollout profile runs the same script under constant load, starting from
the image of an older commit built with git archive.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hang-key names its trigger per run, turns SIGTERM and SIGHUP into an
interrupt so the trigger is always dropped and the replica unpaused, and
prints the cleanup SQL if dropping fails. idle-conns reports who closed
the idle connections and can read the pool of another LB container, so a
variant LB config can be checked against the same replicas. bench_compare
refuses a label measured without the load balancer. Stale numbers removed
from the haproxy.cfg comment.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HAProxy checks get fastinter 500ms and timeout check 2.5s (hung replica
detected within 6.5 s), http-reuse never with uvicorn keep-alive 60 s so
the LB closes idle replica connections, and app connections set
idle_in_transaction_session_timeout so a frozen replica releases its
idempotency key. The bench stand runs behind HAProxy with N replicas and
gains the failover profile (make bench_failover / bench_failover_quick):
constant-rate writes with a key and reads while each replica is stopped,
killed or paused, with per-second timeline, detection and recovery time
and write reconciliation. Driver commands idle-conns and hang-key check
the keep-alive and hung-transaction decisions.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
HAProxy 3.4 is the only published entry point; api runs as
API_REPLICAS replicas without ports, found through Docker DNS and
checked on /health/ready. Retries only on connection failure, LB errors
in the contract error format, resource limits and per-service secrets.
Adds scripts/stop-one.sh, LB-aware restart.sh, make replicas /
instances / lb_stats and replica tests driven by EXPECT_REPLICAS.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- carry the lab 2 solution over and plan lab 3 (PLAN.md, OpenSpec
change instance-id-idempotency)
- rename the compose project to mtusi-lab3 and the image to :lab3
- add X-Instance-Id to every response and instance_id to every log
record ([app] instance_id, hostname by default)
- require Idempotency-Key on POST messages: keys table in Postgres,
key and message in one transaction, replay returns the same 201,
another body gets 409, TTL from [idempotency] ttl_seconds
- send the key from student-tests, k6 scenarios and the skill driver;
add idempotency, X-Instance-Id, key race and fault tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>