Реализовать lab3: HAProxy, API×N, идемпотентность и трек 1.
Горизонтальное масштабирование за LB с общими сессиями Redis, X-Instance-Id, обязательным Idempotency-Key в PostgreSQL, сценариями failover/persistence и измерением цены масштабирования при фиксированном CPU/RAM бюджете.
This commit is contained in:
Executable
+66
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Сводка JSON-прогонов трека 1 в evidence/track1/summary.md и summary.json."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
OUT = ROOT / "evidence" / "track1"
|
||||
|
||||
ORDER = [
|
||||
"fixed_budget_n1",
|
||||
"fixed_budget_n2",
|
||||
"fixed_budget_n4",
|
||||
"grow_n2_small",
|
||||
"grow_n2_medium",
|
||||
"grow_n2_large",
|
||||
]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
rows = []
|
||||
for name in ORDER:
|
||||
path = OUT / f"{name}.json"
|
||||
if not path.exists():
|
||||
continue
|
||||
data = json.loads(path.read_text())
|
||||
rows.append(
|
||||
{
|
||||
"label": name,
|
||||
"successful_rps": data.get("successful_rps"),
|
||||
"error_ratio": data.get("error_ratio"),
|
||||
"p50_ms": (data.get("successful_latency_ms") or {}).get("p50"),
|
||||
"p95_ms": (data.get("successful_latency_ms") or {}).get("p95"),
|
||||
"p99_ms": (data.get("successful_latency_ms") or {}).get("p99"),
|
||||
"successful_requests": data.get("successful_requests"),
|
||||
"failed_requests": data.get("failed_requests"),
|
||||
"concurrency": data.get("concurrency"),
|
||||
"elapsed_seconds": data.get("elapsed_seconds"),
|
||||
}
|
||||
)
|
||||
summary = {"runs": rows}
|
||||
OUT.mkdir(parents=True, exist_ok=True)
|
||||
(OUT / "summary.json").write_text(json.dumps(summary, ensure_ascii=False, indent=2) + "\n")
|
||||
|
||||
lines = [
|
||||
"# Track 1 summary",
|
||||
"",
|
||||
"Closed-loop `tests/load.py` (duration=30, concurrency=8). RPS — только успешные HTTP 201.",
|
||||
"",
|
||||
"| label | RPS | err_ratio | p50 ms | p95 ms | p99 ms | ok | fail |",
|
||||
"| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |",
|
||||
]
|
||||
for r in rows:
|
||||
lines.append(
|
||||
"| {label} | {successful_rps} | {error_ratio} | {p50_ms} | {p95_ms} | {p99_ms} | {successful_requests} | {failed_requests} |".format(
|
||||
**r
|
||||
)
|
||||
)
|
||||
lines.append("")
|
||||
(OUT / "summary.md").write_text("\n".join(lines) + "\n")
|
||||
print((OUT / "summary.md").read_text())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user