Files
mtusi2026lab2/bench/k6/write.js
T
ricoromaandClaude Opus 5.5 e76eed789f feat: run load bench on PostgreSQL with query plans
- bench stand is a separate compose project mtusi-bench (API, Postgres,
  Valkey) with fixed limits, fresh volume per size and migrations
- k6 registers with a password, logs in with Basic and sends Bearer
- VACUUM (ANALYZE) and CHECKPOINT after prefill
- EXPLAIN (ANALYZE, BUFFERS) of the app's history query via auto_explain,
  plus the same query without the index in a rolled back transaction
- Postgres CPU, table and index size in results; storages in passport
- bench_compare checks storage limits, images and settings
- remove inproc.py and make bench_inproc

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 01:21:15 +03:00

44 lines
1.1 KiB
JavaScript

// Сценарий write: ровно COUNT сообщений в чат записи от участников по
// кругу, VUS клиентов одновременно. Читаемый чат не меняется.
import exec from "k6/execution";
import {
SUMMARY_THRESHOLDS,
SUMMARY_TREND_STATS,
WORK_DIR,
sendMessage,
summaryFiles,
syntheticText,
} from "./lib.js";
const fixture = JSON.parse(open(`${WORK_DIR}/fixture.json`));
const OFFSET = Number(__ENV.OFFSET || 0);
export const options = {
scenarios: {
write: {
executor: "shared-iterations",
vus: Number(__ENV.VUS),
iterations: Number(__ENV.COUNT),
maxDuration: "10m",
},
},
discardResponseBodies: true,
summaryTrendStats: SUMMARY_TREND_STATS,
thresholds: SUMMARY_THRESHOLDS,
};
export default function () {
const n = OFFSET + exec.scenario.iterationInTest;
const sender = fixture.memberIds[n % fixture.memberIds.length];
sendMessage(
fixture.writeChatId,
fixture.tokens[sender],
syntheticText("w", n),
);
}
export function handleSummary(data) {
return summaryFiles(data);
}