#!/usr/bin/env python3 """Дополнительная серия трека 1: много CPU у API, узкий Postgres, затем больше CPU у Postgres.""" import json from pathlib import Path import run_track1 as track ROOT = Path(__file__).resolve().parents[1] OUT = ROOT / "evidence" / "track1_db.json" SPECS = { "api2-pg0.35": { "replicas": 2, "api_cpus": 1.0, "api_memory": "512m", "pg_cpus": 0.35, "pool": 10, "concurrency": 16, }, "api4-pg0.35": { "replicas": 4, "api_cpus": 1.0, "api_memory": "512m", "pg_cpus": 0.35, "pool": 10, "concurrency": 16, }, "api2-pg1.50": { "replicas": 2, "api_cpus": 1.0, "api_memory": "512m", "pg_cpus": 1.5, "pool": 10, "concurrency": 16, }, } def main(): token, user_id = track.prepare_actor() rows = [] try: for name, spec in SPECS.items(): rows.extend(track.measure(name, spec, token, user_id)) finally: OUT.write_text(json.dumps(rows, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") track.restore() summary = {name: track.mean_rps(rows, name) for name in SPECS} print(json.dumps(summary, ensure_ascii=False, indent=2)) if __name__ == "__main__": main()