load-test-realtime-subs.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. set -euo pipefail
  21. : "${BRIVEN_RUNTIME_SHARED_SECRET:?env required}"
  22. : "${BRIVEN_LOAD_TEST_PROJECT_ID:?env required}"
  23. : "${BRIVEN_LOAD_TEST_FUNCTION:?env required}"
  24. URL="${BRIVEN_LOAD_TEST_URL:-wss://realtime.briven.tech}"
  25. SUBS="${BRIVEN_LOAD_TEST_SUBS:-1000}"
  26. DURATION="${BRIVEN_LOAD_TEST_DURATION:-60}"
  27. OUT_DIR="tmp/load-tests"
  28. mkdir -p "$OUT_DIR"
  29. STAMP="$(date -u +%Y%m%dT%H%M%SZ)"
  30. OUT_FILE="$OUT_DIR/${STAMP}.txt"
  31. echo "running: $SUBS subs against $URL for ${DURATION}s"
  32. echo "output: $OUT_FILE"
  33. echo
  34. bun run infra/load-tests/realtime-subs.ts \
  35. --url "$URL" \
  36. --secret "$BRIVEN_RUNTIME_SHARED_SECRET" \
  37. --project "$BRIVEN_LOAD_TEST_PROJECT_ID" \
  38. --function "$BRIVEN_LOAD_TEST_FUNCTION" \
  39. --subs "$SUBS" \
  40. --duration "$DURATION" \
  41. 2>&1 | tee "$OUT_FILE"
  42. echo
  43. echo "summary saved to $OUT_FILE"