You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> **Tip: Bypass Bridge Rate Limits in Local/Test**
23
+
24
+
If your bridge server is configured with request rate limiting (e.g. `RPS_LIMIT`), you can bypass these limits for benchmark and development purposes by setting the environment variable `RATE_LIMITS_BY_PASS_TOKEN` to a known token, such as `test-token`.
25
+
The benchmark script will use this token via its `Authorization: Bearer` header, so you should make sure your bridge instantiation command includes this variable:
This instructs the server to exempt any request with `Authorization: Bearer test-token` from rate limits. **Do not use this configuration in production environments.**
35
+
By default, the `bridge_test.js` load script will send this token (unless overridden via the `AUTH_TOKEN` environment variable).
36
+
37
+
3.**Flush Redis data (important for clean test results):**
38
+
39
+
Before running benchmarks, flush Redis data locally to avoid collisions with previous test data:
40
+
```bash
41
+
redis-cli FLUSHALL
42
+
```
43
+
44
+
Or if using a specific Redis database:
45
+
```bash
46
+
redis-cli -n <database_number> FLUSHDB
47
+
```
48
+
49
+
**Note**: This ensures that test results are not affected by stale data from previous test runs, providing accurate and reproducible benchmark results.
50
+
51
+
4.**Run benchmark:**
22
52
```bash
23
53
cd benchmark
24
54
./k6 run bridge_test.js
25
55
```
26
56
57
+
## 📋 Test Overview
58
+
59
+
The `bridge_test.js` script performs end-to-end load testing of the Ton Connect Bridge Server by simulating:
60
+
-**SSE Listeners**: Virtual users that maintain persistent SSE connections to receive messages
61
+
-**Message Senders**: Virtual users that send messages through the bridge
62
+
63
+
The test measures message delivery latency, error rates, and system stability under load.
64
+
65
+
## 🏗️ Test Architecture
66
+
67
+
The test runs two parallel scenarios:
68
+
69
+
### 1. SSE Workers Scenario (`sse`)
70
+
- Maintains persistent SSE connections to `/events` endpoint
71
+
- Listens for incoming messages and measures delivery latency
72
+
- Supports multiple client IDs per VU (configurable via `LISTENER_WRITERS_RATIO`)
73
+
- Automatically reconnects on connection failures
74
+
75
+
### 2. Message Senders Scenario (`senders`)
76
+
- Sends POST requests to `/message` endpoint
77
+
- Uses ramping arrival rate executor to control message sending rate
78
+
- Generates random client IDs within the configured ID space
79
+
- Sends messages with timestamps for latency measurement
80
+
81
+
## ⚙️ Configuration Options
82
+
83
+
All configuration is done via environment variables:
84
+
85
+
-`AUTH_TOKEN` - Bearer token used to authenticate requests to the bridge server and bypass any rate limiting. For local development or testing, you can use a fixed string such as `test-token`; for production-like testing, set this to a valid token if your bridge enforces authentication.
86
+
87
+
### Load Configuration
88
+
-`SSE_VUS` (default: `100`) - Number of SSE listener virtual users
89
+
-`SEND_RATE` (default: `1000`) - Target messages per second to send
90
+
-`LISTENER_WRITERS_RATIO` (default: `3`) - Number of listeners per writer (affects ID space calculation)
91
+
-`TOTAL_INSTANCES` (default: `1`) - Total number of test instances (for distributed testing)
92
+
-`CURRENT_INSTANCE` (default: `0`) - Current instance index (0-based, for distributed testing)
93
+
94
+
### Timing Configuration
95
+
All duration values support `s` (seconds), `m` (minutes), or `h` (hours) suffixes.
96
+
97
+
**SSE Scenario:**
98
+
-`SSE_RAMP_UP` (default: `10s`) - Time to ramp up SSE connections
99
+
-`SSE_HOLD` (default: `50s`) - Duration to maintain steady SSE connections
100
+
-`SSE_RAMP_DOWN` (default: `10s`) - Time to ramp down SSE connections
101
+
-`SSE_DELAY` (default: `0s`) - Delay before starting SSE scenario
102
+
103
+
**Sender Scenario:**
104
+
-`SENDER_RAMP_UP` (default: `10s`) - Time to ramp up message sending rate
105
+
-`SENDER_HOLD` (default: `30s`) - Duration to maintain steady sending rate
106
+
-`SENDER_RAMP_DOWN` (default: `10s`) - Time to ramp down message sending rate
107
+
-`SENDER_DELAY` (default: `10s`) - Delay before starting sender scenario (typically set to allow SSE connections to establish)
108
+
109
+
### Server Configuration
110
+
-`BRIDGE_URL` (default: `http://localhost:8081/bridge`) - Base URL of the bridge server
111
+
112
+
## 📊 Metrics Collected
113
+
114
+
The test tracks the following custom metrics:
115
+
116
+
-**`sse_message_received`** - Counter of messages received via SSE
117
+
-**`sse_message_sent`** - Counter of messages successfully sent
118
+
-**`sse_errors`** - Counter of SSE connection/communication errors
119
+
-**`post_errors`** - Counter of failed POST requests
0 commit comments