# failover-metrics: stop/kill every replica under load, metrics
# date: 2026-10-14 20:26:19, commit: 0ab3a34 + uncommitted changes
# command: python.exe student-tests/failover_metrics.py
# exit code: 0, 69.7 s

api replicas: ['58542a53644c', '9737b915ff2f']; load: 4 writers without pauses + 1 reader, client timeout 2 s, retry with the same Idempotency-Key; 3 s before and 10 s after the failure
--- stop 58542a53644c ...
    docker stop: 4.12 s; HAProxy excluded it after 1.11 s; errors: 0 {}, stopped after 0.0 s
    write RPS before 304.7 -> after 202.2; p95 after 47.0 ms, max 766.0 ms; answers from the stopped replica after stop: 0
    confirmed 2938, in history 2938, lost 0, duplicates 0; back in the balancer 3.25 s after docker start
--- kill 58542a53644c ...
    docker kill: 0.81 s; HAProxy excluded it after 0.11 s; errors: 2 {'502': 2}, stopped after 0.05 s
    write RPS before 328.7 -> after 228.2; p95 after 32.0 ms, max 1015.0 ms; answers from the stopped replica after stop: 0
    confirmed 3274, in history 3274, lost 0, duplicates 0; back in the balancer 1.55 s after docker start
--- stop 9737b915ff2f ...
    docker stop: 4.12 s; HAProxy excluded it after 1.5 s; errors: 0 {}, stopped after 0.0 s
    write RPS before 288.7 -> after 232.7; p95 after 32.0 ms, max 94.0 ms; answers from the stopped replica after stop: 0
    confirmed 3194, in history 3194, lost 0, duplicates 0; back in the balancer 4.09 s after docker start
--- kill 9737b915ff2f ...
    docker kill: 0.83 s; HAProxy excluded it after 0.11 s; errors: 2 {'502': 2}, stopped after 0.05 s
    write RPS before 266.7 -> after 219.9; p95 after 32.0 ms, max 1000.0 ms; answers from the stopped replica after stop: 0
    confirmed 3000, in history 3000, lost 0, duplicates 0; back in the balancer 4.14 s after docker start

replica       mode  cmd,s  lb_out,s  errors  errors_end,s  rps_before  rps_after  p95_after,ms  rejoin,s
58542a53644c  stop   4.12      1.11       0           0.0       304.7      202.2          47.0      3.25
58542a53644c  kill   0.81      0.11       2          0.05       328.7      228.2          32.0      1.55
9737b915ff2f  stop   4.12       1.5       0           0.0       288.7      232.7          32.0      4.09
9737b915ff2f  kill   0.83      0.11       2          0.05       266.7      219.9          32.0      4.14
PASS: every replica was stopped (stop, kill) and restored; no lost or duplicated messages; saved evidence\failover-metrics.json
