Разбить API на модули и перевести комментарии на русский

This commit is contained in:
celis
2026-10-29 22:26:25 +03:00
parent c4f9eb7648
commit e8ba028b89
29 changed files with 630 additions and 456 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
#!/bin/sh
# Track 1: for each "replicas cpus pool" config, step the offered rate and record k6 summary + docker CPU sample.
# Usage: research/bench.sh OUT_DIR "N CPUS POOL" ... (rates from RATES env)
# Трек 1: для каждой конфигурации "реплики cpu пул" ступенчато повышает нагрузку, сохраняет итог k6 и снимок CPU.
# Запуск: research/bench.sh OUT_DIR "N CPUS POOL" ... (ступени RPS — переменная RATES)
set -eu
cd "$(dirname "$0")/.."
out=$1; shift
+6 -6
View File
@@ -1,6 +1,6 @@
// Open-model load profile (constant arrival rate, no coordinated omission):
// WRITE_SHARE of iterations POST a message with a fresh Idempotency-Key, the rest read a history page (limit 20).
// Run through docker on the stand network, see research/README.md.
// Профиль нагрузки open model (постоянная интенсивность, без coordinated omission):
// доля WRITE_SHARE итераций отправляет сообщение с новым Idempotency-Key, остальные читают страницу истории (limit 20).
// Запускается в docker в сети стенда, см. REPORT.md (трек 1).
import http from 'k6/http';
import encoding from 'k6/encoding';
import { Counter } from 'k6/metrics';
@@ -27,7 +27,7 @@ export const options = {
},
},
setupTimeout: '180s',
// Thresholds only create submetrics, so setup() traffic is excluded from the numbers below.
// Пороги нужны только для подметрик: так трафик setup() не попадает в итоговые числа.
thresholds: {
'http_reqs{scenario:load}': ['count>=0'],
'http_req_duration{scenario:load}': ['max>=0'],
@@ -59,7 +59,7 @@ export function setup() {
{ headers: { ...json.headers, Authorization: 'Bearer ' + a.token } });
if (chat.status !== 201) throw new Error('chat ' + chat.status);
const chatId = chat.json('id');
for (let m = 0; m < 20; m++) { // non-empty first history page
for (let m = 0; m < 20; m++) { // непустая первая страница истории
http.post(`${BASE}/api/v1/chats/${chatId}/messages`, JSON.stringify({ text: 'seed ' + m }),
{ headers: { ...json.headers, Authorization: 'Bearer ' + a.token, 'Idempotency-Key': `seed-${chatId}-${m}` } });
}
@@ -87,7 +87,7 @@ export function handleSummary(data) {
const d = m['http_req_duration{scenario:load}'].values;
const reqs = m['http_reqs{scenario:load}'].values.count;
const fails = m.failed_requests ? m.failed_requests.values.count : 0;
const seconds = parseFloat(DURATION); // seconds, e.g. '30s'
const seconds = parseFloat(DURATION); // секунды, например '30s'
const summary = {
offered_rps: RATE,
write_share: WRITE_SHARE,
+2 -2
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Aggregate evidence/track1/raw/*.json (k6 summaries) + *.cpu into a Markdown table and an SVG chart."""
"""Сводит итоги k6 (*.json) и снимки CPU (*.cpu) в Markdown-таблицу и SVG-график."""
import json
import re
import sys
@@ -27,7 +27,7 @@ for cfg, rate, d, cpu in rows:
print(f"| {cfg} | {rate} | {d['successful_rps']} | {d['failed']} | {d['dropped_iterations']} | {l['p50']:.1f} | {l['p95']:.1f} | {l['p99']:.1f} | "
f"{cpu.get('api', 0):.0f} | {cpu.get('postgres', 0):.0f} | {cpu.get('lb', 0):.0f} |")
# SVG: successful RPS vs offered RPS, one line per configuration.
# SVG: успешные RPS от поданной нагрузки, по линии на конфигурацию.
W, H, P = 640, 380, 50
series = {}
for cfg, rate, d, _ in rows: