lab4: слот загрузки держится до конца S3 PUT (буфер жив до него); причины 503 в замере

Замер 32 одновременных загрузок показал: семафор ограничивал только чтение тела, а буферы
копились на этапе S3 PUT (+214 МБ при 4 слотах). Теперь пик при 32 клиентах тот же, что при 16.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alexey Bodanyuk
2026-10-25 14:33:56 +03:00
co-authored by Claude Opus 5.5
parent 4ea6924db1
commit 277d06f5b5
4 changed files with 125 additions and 42 deletions
+6 -2
View File
@@ -144,7 +144,8 @@ def run_scenario(name: str, env: dict, files: list[tuple[bytes, str]]) -> dict:
started = time.perf_counter()
r = c.post(f"/api/v1/chats/{chat_id}/attachments?filename=f{i}", content=data,
headers={"Authorization": "Bearer " + token, "Content-Type": ctype})
results[i] = (r.status_code, time.perf_counter() - started, r.headers.get("x-instance-id", "-"))
reason = r.json()["error"]["message"] if r.status_code != 201 else ""
results[i] = (r.status_code, time.perf_counter() - started, r.headers.get("x-instance-id", "-"), reason)
c.close()
s3_id = sh("docker", "compose", "ps", "-q", "s3").strip()
@@ -178,8 +179,11 @@ def run_scenario(name: str, env: dict, files: list[tuple[bytes, str]]) -> dict:
- per_replica[hostname]["idle_mib"], 1)
lat = sorted(r[1] for r in results if r[0] == 201)
codes: dict[str, int] = {}
reasons: dict[str, int] = {}
for r in results:
codes[str(r[0])] = codes.get(str(r[0]), 0) + 1
if r[3]:
reasons[r[3]] = reasons.get(r[3], 0) + 1
summary = {
"scenario": name, "settings": env, "clients": len(files),
"s3_sampled_max_mib": round(max(samplers[-1].values or [0]) / MiB, 1),
@@ -188,7 +192,7 @@ def run_scenario(name: str, env: dict, files: list[tuple[bytes, str]]) -> dict:
# OOM kills / restarts DURING the scenario (any container of the stand): must be empty
"incidents": {k: v for k, v in container_events().items() if v != restarts_before.get(k)},
"file_mib_each": round(statistics.mean(len(d) for d, _ in files) / MiB, 2),
"types": sorted({t for _, t in files}), "status_codes": codes, "wall_seconds": round(wall, 2),
"types": sorted({t for _, t in files}), "status_codes": codes, "error_reasons": reasons, "wall_seconds": round(wall, 2),
"latency_s": {"p50": round(lat[len(lat) // 2], 2), "max": round(lat[-1], 2)} if lat else None,
"replicas": per_replica,
}