-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrecord-demo.sh
More file actions
executable file
·61 lines (47 loc) · 2.51 KB
/
Copy pathrecord-demo.sh
File metadata and controls
executable file
·61 lines (47 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
set -euo pipefail
# Record a terminal demo of FluxMeter
# Prerequisites: `make build` already done, Docker running
echo "=== Recording FluxMeter Demo ==="
echo ""
# Clean slate
docker compose down -v 2>/dev/null || true
sleep 2
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " FluxMeter: Streaming metering engine for AI token billing"
echo " 1M+ events/sec | Sub-second aggregation | Apache Flink"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "▶ Starting infrastructure (Kafka + Flink + Redis + ClickHouse)..."
docker compose up -d 2>&1 | grep -v "warning\|Pulling\|layer\|Wait\|Download\|Extract"
echo " ✓ All services running"
echo ""
sleep 15
echo "▶ Submitting Flink job..."
JAR="$(ls -t build/libs/fluxmeter-*.jar 2>/dev/null | head -1)"
docker cp "$JAR" fluxmeter-jobmanager:/opt/flink/fluxmeter.jar >/dev/null
docker exec fluxmeter-jobmanager flink run -d -c io.fluxmeter.job.TokenUsageAggregator /opt/flink/fluxmeter.jar 2>&1 | grep "Job has been"
echo ""
sleep 3
echo "▶ Generating 500K token events/sec..."
echo ""
KAFKA_BROKERS=localhost:9094 NUM_CUSTOMERS=10000 NUM_THREADS=4 TARGET_EPS=500000 timeout 20 java -cp "$JAR" io.fluxmeter.generator.LoadGenerator 2>&1 | grep STATS
echo ""
# Flush windows
KAFKA_BROKERS=localhost:9094 NUM_CUSTOMERS=100 NUM_THREADS=1 TARGET_EPS=10000 timeout 15 java -cp "$JAR" io.fluxmeter.generator.LoadGenerator >/dev/null 2>&1
echo "▶ Real-time aggregation results (from Redis):"
echo ""
echo " Events metered: $(docker exec fluxmeter-redis redis-cli GET global:total_events)"
echo " Tokens counted: $(docker exec fluxmeter-redis redis-cli GET global:total_tokens)"
echo " Cost calculated: \$$(docker exec fluxmeter-redis redis-cli GET global:total_cost_usd)"
echo ""
echo "▶ Baseline comparison: Flink vs ClickHouse"
echo ""
./baseline/benchmark.sh
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " FluxMeter — github.com/10kshuaizhang/fluxmeter"
echo " make demo — try it yourself"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
# Cleanup
docker compose down 2>/dev/null || true