load-test-realtime-subs.sh50 lines · main
1#!/usr/bin/env bash
2# Realtime-subscriptions load test runner.
3#
4# Wraps infra/load-tests/realtime-subs.ts with sensible defaults so the
5# Phase 2 exit criterion (1,000 concurrent subs on KVM4 with p99 fan-out
6# under 500ms, zero connection failures) can be exercised with one
7# command. Writes the run summary to ./tmp/load-tests/<utc-timestamp>.txt
8# so subsequent runs are comparable.
9#
10# Required env:
11# BRIVEN_RUNTIME_SHARED_SECRET — the shared secret the realtime
12# service expects on subscribe; see infra/dokploy/.env on the host.
13# BRIVEN_LOAD_TEST_PROJECT_ID — the project to fan out to.
14# BRIVEN_LOAD_TEST_FUNCTION — a deployed function name (any cheap one).
15#
16# Optional:
17# BRIVEN_LOAD_TEST_URL — wss URL. Defaults to wss://realtime.briven.tech.
18# BRIVEN_LOAD_TEST_SUBS — concurrent connection count. Default 1000.
19# BRIVEN_LOAD_TEST_DURATION — seconds to hold. Default 60.
20
21set -euo pipefail
22
23: "${BRIVEN_RUNTIME_SHARED_SECRET:?env required}"
24: "${BRIVEN_LOAD_TEST_PROJECT_ID:?env required}"
25: "${BRIVEN_LOAD_TEST_FUNCTION:?env required}"
26
27URL="${BRIVEN_LOAD_TEST_URL:-wss://realtime.briven.tech}"
28SUBS="${BRIVEN_LOAD_TEST_SUBS:-1000}"
29DURATION="${BRIVEN_LOAD_TEST_DURATION:-60}"
30
31OUT_DIR="tmp/load-tests"
32mkdir -p "$OUT_DIR"
33STAMP="$(date -u +%Y%m%dT%H%M%SZ)"
34OUT_FILE="$OUT_DIR/${STAMP}.txt"
35
36echo "running: $SUBS subs against $URL for ${DURATION}s"
37echo "output: $OUT_FILE"
38echo
39
40bun run infra/load-tests/realtime-subs.ts \
41 --url "$URL" \
42 --secret "$BRIVEN_RUNTIME_SHARED_SECRET" \
43 --project "$BRIVEN_LOAD_TEST_PROJECT_ID" \
44 --function "$BRIVEN_LOAD_TEST_FUNCTION" \
45 --subs "$SUBS" \
46 --duration "$DURATION" \
47 2>&1 | tee "$OUT_FILE"
48
49echo
50echo "summary saved to $OUT_FILE"