|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -euo pipefail |
| 4 | + |
| 5 | +VIP="${1:?Usage: $0 <virtual-ip-address>}" |
| 6 | +SUPERSET_URL="https://${VIP}" |
| 7 | +ITERATIONS="${2:-50}" |
| 8 | + |
| 9 | +echo "=== Superset Cluster Benchmark ===" |
| 10 | +echo "Target: ${SUPERSET_URL}" |
| 11 | +echo "Iterations: ${ITERATIONS}" |
| 12 | +echo |
| 13 | + |
| 14 | +echo "--- Login throughput ---" |
| 15 | +LOGIN_PAYLOAD='{"username":"superset","password":"cluster","provider":"db","refresh":true}' |
| 16 | +START=$(date +%s%N) |
| 17 | +for i in $(seq 1 "${ITERATIONS}"); do |
| 18 | + curl --silent --insecure --output /dev/null --write-out "%{http_code} %{time_total}s\n" \ |
| 19 | + --url "${SUPERSET_URL}/api/v1/security/login" \ |
| 20 | + --header "Content-Type: application/json" \ |
| 21 | + --data "${LOGIN_PAYLOAD}" |
| 22 | +done |
| 23 | +END=$(date +%s%N) |
| 24 | +echo "Total: $(( (END - START) / 1000000 ))ms for ${ITERATIONS} requests" |
| 25 | +echo |
| 26 | + |
| 27 | +echo "--- Dashboard API latency ---" |
| 28 | +TOKEN=$(curl --silent --insecure \ |
| 29 | + --url "${SUPERSET_URL}/api/v1/security/login" \ |
| 30 | + --header "Content-Type: application/json" \ |
| 31 | + --data "${LOGIN_PAYLOAD}" | python3 -c "import sys,json; print(json.load(sys.stdin)['access_token'])") |
| 32 | + |
| 33 | +for endpoint in "/api/v1/dashboard/" "/api/v1/database/" "/api/v1/chart/"; do |
| 34 | + echo -n "${endpoint}: " |
| 35 | + curl --silent --insecure --output /dev/null --write-out "%{time_total}s\n" \ |
| 36 | + --url "${SUPERSET_URL}${endpoint}" \ |
| 37 | + --header "Authorization: Bearer ${TOKEN}" |
| 38 | +done |
| 39 | +echo |
| 40 | + |
| 41 | +echo "--- Redis latency (from mgmt node) ---" |
| 42 | +ssh superset@node-0 "docker exec redis redis-cli --latency-history --latency-dist -i 1 2>/dev/null | head -5" \ |
| 43 | + 2>/dev/null || echo "Redis latency check requires SSH access to node-0" |
| 44 | +echo |
| 45 | +echo "=== Benchmark complete ===" |
0 commit comments