@@ -6,20 +6,49 @@ This directory contains load testing scenarios for validating EventKit's perform
66
77### 1. Start EventKit
88
9+ Choose your queue mode:
10+
11+ ** AsyncQueue Mode (Single-Server, In-Process)** :
12+ ``` bash
13+ # Terminal 1: Start EventKit API with AsyncQueue
14+ GCP_PROJECT_ID=eventkit-benchmark \
15+ GCP_GCS_BUCKET=eventkit-events \
16+ STORAGE_EMULATOR_HOST=http://localhost:4443 \
17+ EVENTKIT_RING_BUFFER_ENABLED=true \
18+ EVENTKIT_QUEUE_MODE=async \
19+ uv run uvicorn eventkit.api.app:app --host=0.0.0.0 --port=8000
20+ ```
21+
22+ ** PubSub Mode (Distributed, External Queue)** :
923``` bash
10- # Terminal 1: Start EventKit API
11- cd /path/to/eventkit
12- uvicorn eventkit.api.app:app --host=0.0.0.0 --port=8000
24+ # Terminal 1: Start Pub/Sub + GCS emulators
25+ docker compose up -d pubsub-emulator gcs-emulator
26+
27+ # Terminal 2: Start EventKit API with PubSub
28+ GCP_PROJECT_ID=eventkit-benchmark \
29+ GCP_GCS_BUCKET=eventkit-events \
30+ PUBSUB_EMULATOR_HOST=localhost:8085 \
31+ STORAGE_EMULATOR_HOST=http://localhost:9023 \
32+ EVENTKIT_RING_BUFFER_ENABLED=true \
33+ EVENTKIT_QUEUE_MODE=pubsub \
34+ EVENTKIT_PUBSUB_TOPIC=eventkit-events \
35+ uv run uvicorn eventkit.api.app:app --host=0.0.0.0 --port=8000
36+
37+ # Terminal 3: Start EventSubscriptionCoordinator workers
38+ # (Implementation specific - see streaming/coordinator.py for examples)
1339```
1440
1541### 2. Run All Benchmarks
1642
1743``` bash
18- # Terminal 2: Run benchmark suite
19- ./benchmarks/run_benchmarks.sh
44+ # Test AsyncQueue mode
45+ ./benchmarks/run_benchmarks.sh async
46+
47+ # Or test PubSub mode
48+ ./benchmarks/run_benchmarks.sh pubsub
2049```
2150
22- This will run all scenarios and save results to ` benchmarks/results/ ` .
51+ Results will be saved to ` benchmarks/results/{queue_mode} / ` .
2352
2453## Manual Testing
2554
@@ -171,6 +200,63 @@ uv run memray run -o memory.bin \
171200memray flamegraph memory.bin
172201```
173202
203+ ## Comparing Queue Modes
204+
205+ EventKit supports two queue modes with different trade-offs:
206+
207+ ### AsyncQueue (Single-Server)
208+ ** Best for** : Development, single-instance deployments
209+
210+ ** Characteristics** :
211+ - In-process Python ` asyncio.Queue `
212+ - Low latency (microseconds to enqueue)
213+ - No external dependencies
214+ - Simpler architecture
215+ - Limited to single server's resources
216+
217+ ** Benchmark this to measure** :
218+ - Maximum throughput for single instance
219+ - Memory pressure under load
220+ - Ring buffer → queue → loader latency
221+
222+ ### PubSub (Distributed)
223+ ** Best for** : Production, horizontal scaling
224+
225+ ** Characteristics** :
226+ - External queue (Google Cloud Pub/Sub)
227+ - Higher latency (milliseconds to publish)
228+ - Distributed processing
229+ - Horizontal scalability
230+ - More complex architecture
231+
232+ ** Benchmark this to measure** :
233+ - Network overhead (API → Pub/Sub)
234+ - Multi-worker scalability
235+ - Fault tolerance (nack/redelivery)
236+
237+ ### Running Comparisons
238+
239+ ``` bash
240+ # Benchmark AsyncQueue (single emulator needed)
241+ docker compose up -d gcs-emulator
242+ ./benchmarks/run_benchmarks.sh async
243+
244+ # Benchmark PubSub (both emulators needed)
245+ docker compose up -d pubsub-emulator gcs-emulator
246+ ./benchmarks/run_benchmarks.sh pubsub
247+
248+ # Compare results
249+ diff benchmarks/results/async/baseline.log \
250+ benchmarks/results/pubsub/baseline.log
251+
252+ # Stop emulators when done
253+ docker compose down
254+ ```
255+
256+ ** What to expect** :
257+ - ** AsyncQueue** : Higher throughput, lower latency (no network hops)
258+ - ** PubSub** : Lower throughput (network + serialization overhead), but horizontally scalable
259+
174260## Configuration Tuning
175261
176262Test different configurations by setting environment variables:
@@ -187,7 +273,7 @@ export EVENTKIT_RING_BUFFER_ENABLED=false
187273export EVENTKIT_EVENT_LOADER_FLUSH_INTERVAL=60
188274
189275# Run benchmarks
190- ./benchmarks/run_benchmarks.sh
276+ ./benchmarks/run_benchmarks.sh async
191277```
192278
193279## Expected Results
0 commit comments